Class: Admin::PasswordResetsController

Inherits:
AdminController show all
Defined in:
app/controllers/admin/password_resets_controller.rb

Instance Attribute Summary

Attributes included from PagesCore::Authentication

#current_user

Instance Method Summary collapse

Methods inherited from PagesCore::AdminController

#redirect, underscore

Methods included from PagesCore::StaticCacheController

#disable_static_cache!

Methods included from PagesCore::PoliciesHelper

#policy, #verify_policy, #verify_policy_with_proc

Methods included from PagesCore::ProcessTitler

inc_number_of_requests, original_title

Methods included from PagesCore::ErrorRenderer

#render_error

Methods included from PagesCore::Authentication

#authenticate!, #deauthenticate!, #logged_in?

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/admin/password_resets_controller.rb', line 11

def create
  @user = find_user_by_email(params[:email])
  if @user
    @password_reset_token = @user.password_reset_tokens.create
    deliver_password_reset(@user, @password_reset_token)
    flash[:notice] = t("pages_core.password_reset.sent")
  else
    flash[:notice] = t("pages_core.password_reset.not_found")
  end
  redirect_to 
end

#showObject



23
24
25
# File 'app/controllers/admin/password_resets_controller.rb', line 23

def show
  @user = @password_reset_token.user
end

#updateObject



27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/admin/password_resets_controller.rb', line 27

def update
  @user = @password_reset_token.user
  if user_params[:password].present? && @user.update(user_params)
    @password_reset_token.destroy
    authenticate!(@user)
    flash[:notice] = t("pages_core.password_reset.changed")
    redirect_to 
  else
    render action: :show
  end
end