Class: ResetPasswordsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ResetPasswordsController
- Defined in:
- lib/generators/fetty/authentication/templates/controllers/reset_passwords_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/generators/fetty/authentication/templates/controllers/reset_passwords_controller.rb', line 7 def create if @user = User.first(:conditions => { :username => params[:login] }) || User.first(:conditions => { :email => params[:login] }) if @user.activated? @user.send_forgot_password_instructions! flash.now[:notice] = "We've sent an email to #{@user.email} containing instructions on how to reset your password." render :action => 'new' else raise "Account has never been activated, please activate your account first before resetting your password." end else raise "Could not find any account with that username / email address." end rescue Exception => e flash.now[:alert] = e. render :action => 'new' end |
#edit ⇒ Object
24 25 26 27 28 |
# File 'lib/generators/fetty/authentication/templates/controllers/reset_passwords_controller.rb', line 24 def edit unless @user = User.first(:conditions => { :id => params[:id], :token => params[:token] }) redirect_to new_reset_password_url, :alert => "Unable to find an account, Please follow the URL from your email / send the new reset instructions!" end end |
#new ⇒ Object
4 5 |
# File 'lib/generators/fetty/authentication/templates/controllers/reset_passwords_controller.rb', line 4 def new end |
#update ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/generators/fetty/authentication/templates/controllers/reset_passwords_controller.rb', line 30 def update if @user = User.first(:conditions => { :id => params[:id], :token => params[:token] }) if @user.reset_password(params[:password],params[:password_confirmation]) == UsersAuthentication::Status::Valid redirect_to new_session_url, :notice => "Your password was successfully updated, Please login using your new password!" else raise "Unable to reset your password!" end else raise "Unable to find an account, Please follow the URL from your email / send the new reset instructions!" end rescue Exception => e flash.now[:alert] = e. render :action => 'edit' end |