docbrown/app/controllers/admin/users_controller.rb
Andy Zhao 0a8f9ca654 Fix URL Validations and Update Admin Dashboard (#1392)
* Validate for trailing slash instead of strict validation

* Remove unused sign_in_count field

* Add profile URLs to edit view

* Add profile URLs to admin controller params

* Add profile URLs to edit view

* Clean up index and search views for user

* Move around user fields to make more sense

* Display more informative label

* Remove name_of_user field in favor of new display label

* Fix typo

* Remove duplication for website, employer, and Mastodon URLs

* Add score to comment params

* Remove unused name_of_user field views

* Fix typo for medium url
2018-12-26 18:00:02 -05:00

58 lines
1.4 KiB
Ruby

module Admin
class UsersController < Admin::ApplicationController
def update
user = User.find(params[:id])
UserRoleService.new(user, current_user.id).check_for_roles(params[:user])
if user.errors.messages.blank? && user.update(user_params)
flash[:notice] = "User successfully updated"
redirect_to "/admin/users/#{params[:id]}"
else
render :new, locals: { page: Administrate::Page::Form.new(dashboard, user) }
end
end
private
def user_params
accessible = %i[
name
email
username
twitter_username
github_username
profile_image
website_url
summary
email_newsletter
email_comment_notifications
email_follower_notifications
organization_id
org_admin
bg_color_hex
text_color_hex
employer_name
employer_url
employment_title
currently_learning
available_for
mostly_work_with
currently_hacking_on
location
email_public
education
feed_url
reputation_modifier
saw_onboarding
scholar_email
facebook_url
behance_url
dribbble_url
medium_url
gitlab_url
linkedin_url
]
accessible << %i[password password_confirmation] unless params[:user][:password].blank?
params.require(:user).permit(accessible)
end
end
end