[Nitro] Nitro-auth 0.2.0 and Nitro/Og 0.22.0

Ysabel deb at ysabel.org
Fri Aug 26 19:42:13 EDT 2005


Given the current upcoming release of nitro 0.23, I'm not going to create a 
release of this unless someone desperately needs it.  However, if you apply 
this patch to nitro-auth 0.2.0, it should work with Nitro/Og 0.22.0.

diff -rN -u old-nitro-auth/lib/nitro/auth/model/user.rb 
new-nitro-auth/lib/nitro/auth/model/user.rb
--- old-nitro-auth/lib/nitro/auth/model/user.rb 2005-08-26 
17:38:08.178362800 -0600
+++ new-nitro-auth/lib/nitro/auth/model/user.rb 2005-08-26 
16:32:56.000000000 -0600
@@ -91,7 +91,13 @@
                 # This is the canonical implementation
                 # roles.include? Role.find_one(:where => "name = 
'#{role.to_s}'")
                 # This is sort of a hack, but turns two queries into one.
-                not find_roles(:extra => "AND #{Role.table}.name = 
'#{role.to_s}'").empty?
+                # not find_roles(:extra => "AND #{Role.table}.name = 
'#{role.to_s}'").empty?
+
+                # In either case, join tables on inherited classes don't
+                # resolve the way they should.  This is a complete
+                # hack, but we'll live.
+                info = User.metadata[:join_tables].first
+                not self.class.find(:sql => "SELECT role.* from 
#{info[:table]} j,#{Role.table} role where j.#{info[:owner_key]} = #{oid} 
and j.#{info[:target_key]} = role.oid and role.name = 
'#{role.to_s}'").empty?
             end
         end


This change is also available in the darcs repository at 
http://darcs.ysabel.org/nitro/nitro-auth if you want to just grab it there. 
Note that this patch will not work on non-SQL stores!

-- 
[ deb at ysabel.org ]          - Ysabel -          [ http://www.ysabel.org/ ]



More information about the Nitro-general mailing list