|
|
|
@@ -212,8 +212,10 @@ class UsersController < ApplicationController |
|
|
|
def update |
|
|
|
return render_not_found unless @user = User.find_by(login: params[:id]) || User.find_by_id(params[:id]) |
|
|
|
return render_forbidden unless User.current.logged? && (current_user&.admin? || current_user.id == @user.id) |
|
|
|
keywords = user_params[:nickname].to_s.each_char.select { |c| c.bytes.first < 240 }.join('') |
|
|
|
return normal_status(-1, "昵称中包含关键词:#{keywords},请重新命名") if ReversedKeyword.check_exists?(keywords) |
|
|
|
if user_params[:nickname].present? |
|
|
|
keywords = user_params[:nickname].to_s.each_char.select { |c| c.bytes.first < 240 }.join('') |
|
|
|
return normal_status(-1, "昵称中包含关键词:#{keywords},请重新命名") if ReversedKeyword.check_exists?(keywords) |
|
|
|
end |
|
|
|
Util.write_file(@image, avatar_path(@user)) if user_params[:image].present? |
|
|
|
@user.attributes = user_params.except(:image) |
|
|
|
unless @user.save |
|
|
|
|