Allow admins to change user email (#10916)

This commit is contained in:
Ben Halpern 2020-10-18 16:28:11 -04:00 committed by GitHub
parent 69f49f88b9
commit 5b063552e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -2,9 +2,11 @@ module ResourceAdmin
class UsersController < ResourceAdmin::ApplicationController
def update
user = User.find(params[:id])
# Email normally needs confirmation. We skip it here when acting as admin
user.update_column(:email, user_params[:email]) if user_params[:email].present?
if user.errors.messages.blank? && user.update(user_params)
flash[:notice] = "User successfully updated"
redirect_to "/ResourceAdmin/users/#{params[:id]}"
redirect_to "/resource_admin/users/#{params[:id]}"
else
render :new, locals: { page: Administrate::Page::Form.new(dashboard, user) }
end

View file

@ -69,6 +69,7 @@ class UserDashboard < Administrate::BaseDashboard
FORM_ATTRIBUTES = %i[
name
username
email
twitter_username
github_username
profile_image