]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/user.rb
This is the initial implementation of login via OpenID
[rails.git] / app / models / user.rb
index 6ec9e26e64ca56823f0004798880085e89aa3373..eb69dc03148107bc4bd8092382db1b5634957135 100644 (file)
@@ -22,6 +22,7 @@ class User < ActiveRecord::Base
   validates_confirmation_of :pass_crypt#, :message => ' must match the confirmation password'
   validates_uniqueness_of :display_name, :allow_nil => true
   validates_uniqueness_of :email
+  validates_uniqueness_of :openid_url, :allow_nil => true
   validates_length_of :pass_crypt, :within => 8..255
   validates_length_of :display_name, :within => 3..255, :allow_nil => true
   validates_length_of :email, :within => 6..255
@@ -143,14 +144,14 @@ class User < ActiveRecord::Base
   ##
   # returns true if the user has the requested role
   def has_role?(role)
-    roles.inject(false) { |x, r| x or r.role == role }
+    roles.any? { |r| r.role == role }
   end
 
   ##
   # returns the first active block which would require users to view 
   # a message, or nil if there are none.
   def blocked_on_view
-    active_blocks.inject(nil) { |s,x| s || (x.needs_view? ? x : nil) }
+    active_blocks.detect { |b| b.needs_view? }
   end
 
   def delete