Sha256: 8c05aa4aa57cdba7d3ca731d805b375de895fb8ed8f303d4bfcb953fd1694d55
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
class Admin::PasswordResetsController < Admin::BaseController skip_before_action :authenticate before_action :set_user, only: %i[ edit update ] layout "admin/authentication" def new end def edit end def create if @user = Admin::User.find_by(email: params[:email]) send_password_reset_email redirect_to admin_sign_in_path, notice: "Check your email for reset instructions" else redirect_to new_admin_password_reset_path, alert: "Sorry, we didn't recognize that email address" end end def update if @user.update(user_params) redirect_to admin_sign_in_path, notice: "Your password was reset successfully. Please sign in" else redirect_to edit_admin_password_reset_path(token: params[:token]), alert: @user.errors.first.full_message end end private def set_user @user = Admin::User.find_by_token_for!(:password_reset, params[:token]) rescue StandardError redirect_to new_admin_password_reset_path, alert: "That password reset link is invalid" end def user_params params.permit(:password, :password_confirmation) end def send_password_reset_email Admin::UserMailer.with(user: @user).password_reset.deliver_later end end
Version data entries
2 entries across 2 versions & 1 rubygems