fix: user update return info

This commit is contained in:
2021-06-03 15:43:36 +08:00
parent 6b436acfaf
commit 93169f8c96
4 changed files with 22 additions and 27 deletions

View File

@@ -74,11 +74,10 @@ class UsersController < ApplicationController
def update
return render_not_found unless @user = User.find_by_id(params[:id]) || User.find_by(login: params[:id])
return render_forbidden unless User.current.logged? && (current_user&.admin? || current_user.id == @user.id)
Util.write_file(@image, avatar_path(@user)) if user_params[:image].present?
@user.attributes = user_params.except(:image)
if @user.save
render_ok
else
unless @user.save
render_error(@user.errors.full_messages.join(", "))
end
end