Sha256: fa04fff0b01d3d360c6c3d92109f1ba15b4243e17ae0761c8ed98264c2aa1463
Contents?: true
Size: 1.3 KB
Versions: 6
Compression:
Stored size: 1.3 KB
Contents
class PasswordResetsController < ApplicationController skip_before_action :authenticate before_action :set_<%= singular_table_name %>, only: %i[ edit update ] def new end def edit end def create if <%= singular_table_name %> = <%= class_name %>.find_by(email: params[:email], verified: true) IdentityMailer.with(<%= singular_table_name %>: <%= singular_table_name %>).password_reset_provision.deliver_later redirect_to sign_in_path, notice: "Check your email for reset instructions" else redirect_to new_password_reset_path, alert: "You can't reset your password until you verify your email" end end def update if @<%= singular_table_name %>.update(<%= "#{singular_table_name}_params" %>) redirect_to sign_in_path, notice: "Your password was reset successfully. Please sign in" else render :edit, status: :unprocessable_entity end end private def set_<%= singular_table_name %> @<%= singular_table_name %> = <%= class_name %>.find_signed!(params[:token], purpose: :password_reset) rescue redirect_to new_password_reset_path, alert: "That password reset link is invalid" end def <%= "#{singular_table_name}_params" %> params.require(:<%= singular_table_name %>).permit(:password, :password_confirmation) end end
Version data entries
6 entries across 6 versions & 1 rubygems