forked from jasder/forgeplus
修改bug
This commit is contained in:
parent
af62da7ae6
commit
17ad972b38
|
@ -1,17 +1,16 @@
|
|||
class Gitea::UserForm
|
||||
include ActiveModel::Model
|
||||
EMAIL_REGEX = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_\-.]+(\.[a-zA-Z0-9_-]+)+$/
|
||||
EMAIL_REGEX = /^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9_\-.]+(\.[a-zA-Z0-9_-]+)+$/
|
||||
|
||||
include ActiveModel::Model
|
||||
attr_accessor :username, :email, :password
|
||||
|
||||
validates :username, presence: true
|
||||
# validates :email, presence: true, format: { with: EMAIL_REGEX, multiline: true }
|
||||
validates :email, presence: true
|
||||
validates :email, presence: true, format: { with: EMAIL_REGEX, multiline: true }
|
||||
|
||||
validates :password, presence: true
|
||||
|
||||
# validate :check_username, :check_email
|
||||
validate :check_username, :check_email
|
||||
|
||||
attr_reader :record
|
||||
|
||||
|
|
|
@ -26,10 +26,6 @@ module Gitea
|
|||
render_result(response)
|
||||
rescue Exception => exception
|
||||
Rails.logger.info "Exception ===========> #{exception.message}"
|
||||
failed_dic = "public/sync_failed_users.dic"
|
||||
File.open(failed_dic,"a") do |file|
|
||||
file.puts "user_info---#{params},errors--#{exception.message}"
|
||||
end
|
||||
fail!(exception.message)
|
||||
end
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ class SyncForgeJob < ApplicationJob
|
|||
if new_user.present?
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
user_params = user_params["user"] if old_version_source.include?(platform)
|
||||
Watcher&.where(user_id: user_params["id"]).update_all(user_id: new_user.id)
|
||||
ProjectTrend&.where(user_id: user_params["id"]).update_all(user_id: new_user.id)
|
||||
sync_roles(roles_params, platform)
|
||||
|
@ -55,6 +56,8 @@ class SyncForgeJob < ApplicationJob
|
|||
private
|
||||
|
||||
def sync_user(owner_params,owner_extension_params,platform)
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
Rails.logger.info("#######______sync_user_start__########")
|
||||
keys_other_delete = %w(id created_at updated_at user_id)
|
||||
keys_to_delete = %w(id created_on updated_on platform)
|
||||
|
@ -73,6 +76,7 @@ class SyncForgeJob < ApplicationJob
|
|||
new_user.save(:validate => false)
|
||||
|
||||
interactor = Gitea::RegisterInteractor.call({username: owner_params["login"], email: owner_params["mail"], password: user_password})
|
||||
|
||||
if interactor.success?
|
||||
gitea_user = interactor.result
|
||||
gitea_uid = gitea_user['id']
|
||||
|
@ -105,6 +109,15 @@ class SyncForgeJob < ApplicationJob
|
|||
end
|
||||
|
||||
new_user
|
||||
|
||||
rescue Exception => e
|
||||
failed_dic = "public/sync_failed_users.dic"
|
||||
File.open(failed_dic,"a") do |file|
|
||||
file.puts "user_info---#{owner_params},errors--#{e}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def random_password
|
||||
|
|
Loading…
Reference in New Issue