Sha256: 4f67257d4a9017d829fa824c0114713bfc6869c55191f34a248173c70ce00e91
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
module Users module Emails class ResetPasswordsController < ActionController::Base # Acción para solicitar el restablecimiento de contraseña def create user = User.find_by(email: params[:email]) if user user.send_reset_email_password_instructions response.headers['X-Password-Reset-Message'] = I18n.t("shieldify.controllers.emails.reset_passwords.create.success") response.headers['X-Password-Reset-Status'] = 'success' else response.headers['X-Password-Reset-Message'] = I18n.t("shieldify.controllers.emails.reset_passwords.create.failure") response.headers['X-Password-Reset-Status'] = 'error' end redirect_to(Shieldify::Configuration.after_request_reset_password_url, allow_other_host: true) end # Acción para actualizar la contraseña def update user = User.find_by_reset_email_password_token(params[:token]) if user if user.reset_password(new_password: params[:password], new_password_confirmation: params[:password_confirmation]) response.headers['X-Password-Reset-Message'] = I18n.t("shieldify.controllers.emails.reset_passwords.update.success") response.headers['X-Password-Reset-Status'] = 'success' else response.headers['X-Password-Reset-Message'] = user.errors.full_messages.last response.headers['X-Password-Reset-Status'] = 'error' end else response.headers['X-Password-Reset-Message'] = I18n.t("shieldify.controllers.emails.reset_passwords.update.failure") response.headers['X-Password-Reset-Status'] = 'error' end redirect_to(Shieldify::Configuration.after_reset_password_url, allow_other_host: true) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shieldify-0.2.0.pre.alpha | app/controllers/users/emails/reset_passwords_controller.rb |