Browse Source

fixed 更新时判断是否有昵称

pull/338/head
xxq250 2 years ago
parent
commit
a136a0468e
1 changed files with 4 additions and 2 deletions
  1. +4
    -2
      app/controllers/users_controller.rb

+ 4
- 2
app/controllers/users_controller.rb View File

@@ -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…
Cancel
Save