fixed 更新时判断是否有昵称
This commit is contained in:
parent
dd914595fa
commit
349c775404
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue