FIX code review
This commit is contained in:
parent
4676b756e8
commit
cbf8f1fa67
|
@ -9,7 +9,7 @@ class AccountsController < ApplicationController
|
|||
# 其他平台同步注册的用户
|
||||
def remote_register
|
||||
username = params[:username]&.gsub(/\s+/, "")
|
||||
tip_exception("无法使用以下关键词:#{username},请重新命名") if ReversedKeyword.is_reversed(username).present?
|
||||
tip_exception("无法使用以下关键词:#{username},请重新命名") if ReversedKeyword.check_exists?(username)
|
||||
email = params[:email]&.gsub(/\s+/, "")
|
||||
password = params[:password]
|
||||
platform = (params[:platform] || 'forge')&.gsub(/\s+/, "")
|
||||
|
|
|
@ -26,7 +26,7 @@ class Organizations::OrganizationsController < Organizations::BaseController
|
|||
|
||||
def create
|
||||
ActiveRecord::Base.transaction do
|
||||
tip_exception("无法使用以下关键词:#{organization_params[:name]},请重新命名") if ReversedKeyword.is_reversed(organization_params[:name]).present?
|
||||
tip_exception("无法使用以下关键词:#{organization_params[:name]},请重新命名") if ReversedKeyword.check_exists?(organization_params[:name])
|
||||
Organizations::CreateForm.new(organization_params).validate!
|
||||
@organization = Organizations::CreateService.call(current_user, organization_params)
|
||||
Util.write_file(@image, avatar_path(@organization)) if params[:image].present?
|
||||
|
|
|
@ -23,7 +23,7 @@ class BaseForm
|
|||
end
|
||||
|
||||
def check_reversed_keyword(repository_name)
|
||||
raise "项目标识已被占用." if ReversedKeyword.is_reversed(repository_name).exists?
|
||||
raise "项目标识已被占用." if ReversedKeyword.check_exists?(repository_name)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@ module Register
|
|||
def check_login
|
||||
raise("登录名格式有误") unless strip_value =~ CustomRegexp::LOGIN
|
||||
|
||||
login_exist = Owner.exists?(login: strip_value) || ReversedKeyword.exists?(identifier: strip_value)
|
||||
login_exist = Owner.exists?(login: strip_value) || ReversedKeyword.check_exists?(strip_value)
|
||||
raise('登录名已被使用') if login_exist
|
||||
end
|
||||
|
||||
|
|
|
@ -18,6 +18,10 @@ class ReversedKeyword < ApplicationRecord
|
|||
|
||||
before_validation :set_identifier
|
||||
|
||||
def self.check_exists?(identifier)
|
||||
self.is_reversed(identifier).exists?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_identifier
|
||||
|
|
Loading…
Reference in New Issue