Sha256: c5901f8e79b09c27d5170bbeac92553ffbdf6968b1bff41946bf3b106bfd1a7e
Contents?: true
Size: 1.3 KB
Versions: 2
Compression:
Stored size: 1.3 KB
Contents
class PasswordResetsController < ApplicationController before_action :set_<%= singular_table_name %>, only: %i[ edit update ] skip_before_action :authenticate 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
2 entries across 2 versions & 1 rubygems