forked from jasder/forgeplus
修改bug
This commit is contained in:
parent
17ad972b38
commit
6ab29a4051
|
@ -79,37 +79,39 @@ class SyncForgeJob < ApplicationJob
|
||||||
|
|
||||||
if interactor.success?
|
if interactor.success?
|
||||||
gitea_user = interactor.result
|
gitea_user = interactor.result
|
||||||
gitea_uid = gitea_user['id']
|
# gitea_uid = gitea_user['id']
|
||||||
# new_user.gitea_uid = gitea_user['id']
|
new_user.gitea_uid = gitea_user['id']
|
||||||
else
|
else
|
||||||
response = Gitea::User::GetTokenService.new("#{owner_params["login"]}").call
|
response = Gitea::User::GetTokenService.new("#{owner_params["login"]}").call
|
||||||
if response.status == 200
|
if response.status == 200
|
||||||
gitea_uid = JSON.parse(response.body)["id"]
|
gitea_uid = JSON.parse(response.body)["id"]
|
||||||
# new_user.gitea_uid = user_id
|
new_user.gitea_uid = user_id
|
||||||
else
|
else
|
||||||
gitea_uid = ""
|
# gitea_uid = ""
|
||||||
|
new_user.gitea_uid = ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
result = Gitea::User::GenerateTokenService.new(owner_params["login"], user_password).call
|
result = Gitea::User::GenerateTokenService.new(owner_params["login"], user_password).call
|
||||||
if result != 401
|
if result != 401
|
||||||
gitea_token = result.result['sha1']
|
# gitea_token = result.result['sha1']
|
||||||
# new_user.gitea_token = result.result['sha1']
|
new_user.gitea_token = result.result['sha1']
|
||||||
else
|
else
|
||||||
gitea_token = ""
|
# gitea_token = ""
|
||||||
|
new_user.gitea_token = ""
|
||||||
end
|
end
|
||||||
new_user.update_attributes(gitea_uid: gitea_uid, gitea_token: gitea_token)
|
|
||||||
|
|
||||||
if owner_extension_params.present?
|
# new_user.update_attributes!(gitea_uid: gitea_uid, gitea_token: gitea_token)
|
||||||
owner_extension_params = owner_extension_params["user_extensions"] if old_version_source.include?(platform) #trustie上需要
|
if new_user.save(:validate => false)
|
||||||
owner_extension_params = owner_extension_params&.except!(*keys_other_delete).merge(user_id: new_user.id)
|
if owner_extension_params.present?
|
||||||
UserExtension.create!(owner_extension_params)
|
owner_extension_params = owner_extension_params["user_extensions"] if old_version_source.include?(platform) #trustie上需要
|
||||||
|
owner_extension_params = owner_extension_params&.except!(*keys_other_delete).merge(user_id: new_user.id)
|
||||||
|
UserExtension.create!(owner_extension_params)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Rails.logger.info("#######______sync_user_end__########")
|
Rails.logger.info("#######______sync_user_end__########")
|
||||||
end
|
end
|
||||||
|
|
||||||
new_user
|
new_user
|
||||||
|
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
failed_dic = "public/sync_failed_users.dic"
|
failed_dic = "public/sync_failed_users.dic"
|
||||||
File.open(failed_dic,"a") do |file|
|
File.open(failed_dic,"a") do |file|
|
||||||
|
@ -121,7 +123,7 @@ class SyncForgeJob < ApplicationJob
|
||||||
end
|
end
|
||||||
|
|
||||||
def random_password
|
def random_password
|
||||||
[*('a'..'z'),*(0..9),*('A'..'Z')].shuffle[0..8].join
|
[*('a'..'z'),*(0..9),*('A'..'Z')].shuffle[0..8].join + ['$','#','&','*','@','_'].shuffle[0..2].join
|
||||||
end
|
end
|
||||||
|
|
||||||
#同步项目
|
#同步项目
|
||||||
|
|
Loading…
Reference in New Issue