forked from External/greenlight
GRN2-309: Allows admins to edit a non-local users name and email (#2389)
* Allows admins to edit a non-local users name and email * Fixed edge case
This commit is contained in:
@ -194,6 +194,14 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
helper_method :allowed_file_types
|
||||
|
||||
# Allows admins to edit a user's details
|
||||
def can_edit_user?(user_to_edit, editting_user)
|
||||
return user_to_edit.greenlight_account? if user_to_edit == editting_user
|
||||
|
||||
editting_user.admin_of?(user_to_edit, "can_manage_users")
|
||||
end
|
||||
helper_method :can_edit_user?
|
||||
|
||||
# Returns the page that the logo redirects to when clicked on
|
||||
def home_page
|
||||
return admins_path if current_user.has_role? :super_admin
|
||||
|
@ -92,7 +92,7 @@ class UsersController < ApplicationController
|
||||
|
||||
redirect_path = current_user.admin_of?(@user, "can_manage_users") ? path : edit_user_path(@user)
|
||||
|
||||
unless @user.greenlight_account?
|
||||
unless can_edit_user?(@user, current_user)
|
||||
params[:user][:name] = @user.name
|
||||
params[:user][:email] = @user.email
|
||||
end
|
||||
|
Reference in New Issue
Block a user