forked from jasder/forgeplus
修改错误
This commit is contained in:
parent
3d6155c3b2
commit
0771b2783c
|
@ -62,38 +62,41 @@ class SyncForgeJob < ApplicationJob
|
||||||
|
|
||||||
owner_params = owner_params&.except!(*keys_to_delete)
|
owner_params = owner_params&.except!(*keys_to_delete)
|
||||||
user_password = random_password
|
user_password = random_password
|
||||||
if User.exists?(login: owner_params["login"])
|
new_user = []
|
||||||
new_user = User.find_by(login: owner_params["login"])
|
if owner_params.present?
|
||||||
else
|
if User.exists?(login: owner_params["login"])
|
||||||
new_user = User.new(owner_params.merge(platform: platform))
|
new_user = User.find_by(login: owner_params["login"])
|
||||||
interactor = Gitea::RegisterInteractor.call({username: owner_params["login"], email: owner_params["mail"], password: user_password})
|
|
||||||
if interactor.success?
|
|
||||||
gitea_user = interactor.result
|
|
||||||
new_user.gitea_uid = gitea_user['id']
|
|
||||||
else
|
else
|
||||||
response = Gitea::User::GetTokenService.new("#{owner_params["login"]}").call
|
new_user = User.new(owner_params.merge(platform: platform))
|
||||||
if response.status == 200
|
interactor = Gitea::RegisterInteractor.call({username: owner_params["login"], email: owner_params["mail"], password: user_password})
|
||||||
user_id = JSON.parse(response.body)["id"]
|
if interactor.success?
|
||||||
new_user.gitea_uid = user_id
|
gitea_user = interactor.result
|
||||||
|
new_user.gitea_uid = gitea_user['id']
|
||||||
else
|
else
|
||||||
new_user.gitea_uid = ""
|
response = Gitea::User::GetTokenService.new("#{owner_params["login"]}").call
|
||||||
end
|
if response.status == 200
|
||||||
end
|
user_id = JSON.parse(response.body)["id"]
|
||||||
if new_user.gitea_uid.present?
|
new_user.gitea_uid = user_id
|
||||||
result = Gitea::User::GenerateTokenService.new(owner_params["login"], user_password).call
|
else
|
||||||
new_user.gitea_token = result['sha1']
|
new_user.gitea_uid = ""
|
||||||
end
|
end
|
||||||
|
end
|
||||||
if new_user.save!
|
if new_user.gitea_uid.present?
|
||||||
if owner_extension_params.present?
|
result = Gitea::User::GenerateTokenService.new(owner_params["login"], user_password).call
|
||||||
owner_extension_params = owner_extension_params["user_extensions"] if old_version_source.include?(platform) #trustie上需要
|
new_user.gitea_token = result['sha1']
|
||||||
|
end
|
||||||
owner_extension_params = owner_extension_params&.except!(*keys_other_delete).merge(user_id: new_user.id)
|
|
||||||
UserExtension.create!(owner_extension_params)
|
if new_user.save!
|
||||||
|
if owner_extension_params.present?
|
||||||
|
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__########")
|
||||||
end
|
end
|
||||||
Rails.logger.info("#######______sync_user_end__########")
|
|
||||||
new_user
|
new_user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue