Sha256: 09f60c472f5456f29c3afadc8b4a26b86214fd521235d996e16f0364f4eb890c
Contents?: true
Size: 986 Bytes
Versions: 1
Compression:
Stored size: 986 Bytes
Contents
class UserRequestPasswordResetForm include Model::NonPersistent field :email, type: String validates_presence_of :email validates_format_of :email, with: /@/, message: :invalid_format # validates uniqueness of provider & uid (email) among all users validate do |record| user = User.where( 'emails.email' => record.email ).first unless user record.errors.add :email, :not_registered return end authentication = user.authentications.where( provider: :password, uid: record.email ).first unless authentication record.errors.add :email, :password_login_not_allowed return end end # Returns User object, corresponding to this email address # def user User.where( 'emails.email' => email ).first end # Returns UserEmail object, corresponding to this email address # def authentication user.authentications.where( provider: :password, uid: email ).first end end # class UserRequestPasswordResetForm
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aerogel-users-1.4.3 | db/model/user_request_password_reset_form.rb |