X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/8217c555238d414be9a50a587301f932f5f45035..ca558c692ebecfcf5f7ebb464d4592718f445038:/app/models/user.rb diff --git a/app/models/user.rb b/app/models/user.rb index 6ec9e26e6..eb69dc031 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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