Class: PasswordController
- Inherits:
-
BaseController
- Object
- BaseController
- PasswordController
- Defined in:
- app/controllers/password_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/password_controller.rb', line 8 def create flash[:notice] = t(:'adva.passwords.flash.create.notification') if user = User.find_by_email(params[:user][:email]) token = user.assign_token 'password' user.save! trigger_event user, :password_reset_requested, :token => "#{user.id};#{token}" redirect_to edit_password_url else render :action => :new end end |
#edit ⇒ Object
20 21 22 |
# File 'app/controllers/password_controller.rb', line 20 def edit params[:token] = nil unless current_user # TODO: maybe solve this nicer? end |
#new ⇒ Object
5 6 |
# File 'app/controllers/password_controller.rb', line 5 def new end |
#update ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/password_controller.rb', line 24 def update if current_user && current_user.update_attributes(params[:user].slice(:password)) trigger_event current_user, :password_updated flash[:notice] = t(:'adva.passwords.flash.update.success') authenticate_user(:email => current_user.email, :password => params[:user][:password]) redirect_to root_url else params[:token] = nil # ugh flash[:error] = t(:'adva.passwords.flash.update.failure') render :action => :edit end end |