Skip to content

Instantly share code, notes, and snippets.

@codeperl
Created July 17, 2017 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeperl/02e351691faad39e3b3761819bd2ff0c to your computer and use it in GitHub Desktop.
Save codeperl/02e351691faad39e3b3761819bd2ff0c to your computer and use it in GitHub Desktop.
Sample
def create
redirect_to page.root_url unless current_user_session.nil?
@forgot_password = Auth::Tableless::ForgotPassword.new(auth_permitted_params.tableless_forgot_password)
if @forgot_password.validate(auth_permitted_params.tableless_forgot_password)
forgot_password_service = Auth::ForgotPasswordService.new
unless forgot_password_service.account_holder?(auth_permitted_params.tableless_forgot_password)
flash.now[:warning] = t('auth.forgot_password.create.warning_message')
render :index
else
email_sent = forgot_password_service.send_password_reset_instruction_email(auth_permitted_params.tableless_forgot_password)
if email_sent
redirect_to page.root_url, flash: {info: t('auth.forgot_password.create.info_message')}
else
flash.now[:danger] = t('auth.forgot_password.create.danger.error_message')
render :index
end
end
else
flash.now[:danger] = t('auth.forgot_password.create.danger.invalid_message')
render :index
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment