Backend functionality to let managers update users password
The back button when the user changes the password (in the print password page) redirects to the edit manually page. The routes to access password edit pages has been added, along with the ones to send reset password email and reset password manually.
This commit is contained in:
@@ -5,6 +5,26 @@ class Management::AccountController < Management::BaseController
|
|||||||
def show
|
def show
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
end
|
||||||
|
|
||||||
|
def print_password
|
||||||
|
end
|
||||||
|
|
||||||
|
def reset_password
|
||||||
|
managed_user.send_reset_password_instructions
|
||||||
|
redirect_to management_account_path, notice: t("management.account.edit.password.reset_email_send")
|
||||||
|
end
|
||||||
|
|
||||||
|
def change_password
|
||||||
|
if managed_user.reset_password(params[:user][:password], params[:user][:password])
|
||||||
|
session[:new_password] = params[:user][:password]
|
||||||
|
redirect_to print_password_management_account_path
|
||||||
|
else
|
||||||
|
render :edit_password_manually
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def only_verified_users
|
def only_verified_users
|
||||||
|
|||||||
@@ -44,4 +44,8 @@ class Management::BaseController < ActionController::Base
|
|||||||
def current_budget
|
def current_budget
|
||||||
Budget.current
|
Budget.current
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def clear_password
|
||||||
|
session[:new_password] = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class Management::DocumentVerificationsController < Management::BaseController
|
|||||||
def set_document
|
def set_document
|
||||||
session[:document_type] = params[:document_verification][:document_type]
|
session[:document_type] = params[:document_verification][:document_type]
|
||||||
session[:document_number] = params[:document_verification][:document_number]
|
session[:document_number] = params[:document_verification][:document_number]
|
||||||
|
clear_password
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_document_number
|
def clean_document_number
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ class Management::UsersController < Management::BaseController
|
|||||||
def destroy_session
|
def destroy_session
|
||||||
session[:document_type] = nil
|
session[:document_type] = nil
|
||||||
session[:document_number] = nil
|
session[:document_number] = nil
|
||||||
|
clear_password
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_without_email
|
def user_without_email
|
||||||
|
|||||||
@@ -15,7 +15,14 @@ namespace :management do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
resource :account, controller: "account", only: [:show]
|
resource :account, controller: "account", only: [:show] do
|
||||||
|
get :print_password
|
||||||
|
patch :change_password
|
||||||
|
get :reset_password
|
||||||
|
get :edit_password_email
|
||||||
|
get :edit_password_manually
|
||||||
|
end
|
||||||
|
|
||||||
resource :session, only: [:create, :destroy]
|
resource :session, only: [:create, :destroy]
|
||||||
get 'sign_in', to: 'sessions#create', as: :sign_in
|
get 'sign_in', to: 'sessions#create', as: :sign_in
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user