Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[account][authentication] clean up plugin

  • Loading branch information...
commit 2245058755017ab79be1b892fe90da03d196c7a6 1 parent 0222567
@achiu achiu authored
Showing with 19 additions and 17 deletions.
  1. +19 −17 app/models/plugins/authentication.rb
View
36 app/models/plugins/authentication.rb
@@ -2,23 +2,25 @@ module Plugins
module Authentication
def self.configure(model)
- # fields
- model.key :email, String
- model.key :crypted_password, String
- model.key :salt, String
- model.key :role, String
- # callbacks
- model.before_save :generate_password
- # validations
- model.validates_presence_of :email, :role
- model.validates_presence_of :password, :if => :password_required
- model.validates_presence_of :password_confirmation, :if => :password_required
- model.validates_length_of :password, :within => 4..40, :if => :password_required
- model.validates_confirmation_of :password, :if => :password_required
- model.validates_length_of :email, :within => 3..40
- model.validates_uniqueness_of :email, :case_sensitive => false
- model.validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
- model.validates_format_of :role, :with => /[A-Za-z]/
+ model.class_eval do
+ # fields
+ key :email, String
+ key :crypted_password, String
+ key :salt, String
+ key :role, String
+ # callbacks
+ before_save :generate_password
+ # validations
+ validates_presence_of :email, :role
+ validates_presence_of :password, :if => :password_required
+ validates_presence_of :password_confirmation, :if => :password_required
+ validates_length_of :password, :within => 4..40, :if => :password_required
+ validates_confirmation_of :password, :if => :password_required
+ validates_length_of :email, :within => 3..40
+ validates_uniqueness_of :email, :case_sensitive => false
+ validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
+ validates_format_of :role, :with => /[A-Za-z]/
+ end
end
module ClassMethods
Please sign in to comment.
Something went wrong with that request. Please try again.