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::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


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

def create
  @user = find_user_by_email(params[:username])
  if @user
    @password_reset_token = @user.password_reset_tokens.create
    deliver_password_reset(@user, @password_reset_token)
    flash[:notice] = "An email with further instructions has been sent"
  else
    flash[:notice] = "Couldn't find a user with that email address"
  end
  redirect_to 
end

#showObject


21
22
23
# File 'app/controllers/admin/password_resets_controller.rb', line 21

def show
  @user = @password_reset_token.user
end

#updateObject


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

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