Class: BetterAuthy::PasswordsController
- Inherits:
-
BaseController
- Object
- ApplicationController
- BaseController
- BetterAuthy::PasswordsController
- Defined in:
- app/controllers/better_authy/passwords_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/better_authy/passwords_controller.rb', line 12 def create @forgot_password_form = BetterAuthy::ForgotPasswordForm.new(forgot_password_params) if @forgot_password_form.valid? resource = find_resource_by_email if resource token = resource.generate_password_reset_token! BetterAuthy::PasswordResetMailer.reset_password_instructions( resource, token, scope_name ).deliver_later end # Always show generic message to prevent email enumeration redirect_to send(:"#{scope_name}_login_path"), notice: I18n.t("better_authy.passwords.send_instructions") else render :new, status: :unprocessable_content end end |
#edit ⇒ Object
31 32 33 |
# File 'app/controllers/better_authy/passwords_controller.rb', line 31 def edit @reset_password_form = BetterAuthy::ResetPasswordForm.new(token: params[:token]) end |
#new ⇒ Object
8 9 10 |
# File 'app/controllers/better_authy/passwords_controller.rb', line 8 def new @forgot_password_form = BetterAuthy::ForgotPasswordForm.new end |
#update ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/better_authy/passwords_controller.rb', line 35 def update @reset_password_form = BetterAuthy::ResetPasswordForm.new(reset_password_params) if @reset_password_form.valid? && @resource.reset_password!( @reset_password_form.password, @reset_password_form.password_confirmation ) redirect_to send(:"#{scope_name}_login_path"), notice: I18n.t("better_authy.passwords.updated") else @resource.errors.each do |error| @reset_password_form.errors.add(error.attribute, error.) end render :edit, status: :unprocessable_content end end |