# Include default devise modules. Others available are:
# , :encryptable, :lockable, :timeoutable and :omniauthable, :confirmable
devise :database_authenticatable, :registerable,
- :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable
-
- # Setup accessible (or protected) attributes for your model
- attr_accessible :email, :password, :password_confirmation, :remember_me
+ :recoverable, :rememberable, :trackable, :validatable
- def active_for_authentication?\r
+ def active_for_authentication?
super && (self.approve == 1)
end
end
def self.start(email, passwd)
- a = Admin.find(:first, :conditions => ['email = ?', email])
- if a
- a.password = passwd
- a.password_confirmation = passwd
- else
- a = Admin.create! :email => email, :password => passwd, :password_confirmation => passwd
- end
+ a = Admin.find_or_initialize_by(email: email)
+ a.password = passwd
+ a.password_confirmation = passwd
a.approve = 1
a.save!
end
+ private
+ def admin_params
+ params.require(:admin).permit(:email, :password, :password_confirmation, :remember_me, :authentication_token)
+ end
+
end