Merge branch 'dev_trustie' of http://gitea.trustie.net/jasder/forgeplus into dev_trustie
This commit is contained in:
commit
dbd0c75fa8
|
@ -4,29 +4,37 @@ class CheckGiteaUser
|
||||||
def call
|
def call
|
||||||
SyncLog.sync_log("=====begin to check gitea_user======")
|
SyncLog.sync_log("=====begin to check gitea_user======")
|
||||||
|
|
||||||
all_users = User.select(:id, :gitea_token, :gitea_uid, :mail, :type).where(type: "User", gitea_token: [nil, ""], gitea_uid: [nil, ""])
|
all_users = User.where(type: "User", gitea_token: [nil, ""], gitea_uid: [nil, ""])
|
||||||
if all_users.present?
|
if all_users.present?
|
||||||
new_password = "12345678"
|
new_password = "12345678"
|
||||||
|
# EMAIL_REGEX = /^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9_\-.]+(\.[a-zA-Z0-9_-]+)+$/i
|
||||||
all_users.each do |user|
|
all_users.each do |user|
|
||||||
SyncLog.sync_log("=====check_user_login_is:#{user.login}======")
|
begin
|
||||||
ActiveRecord::Base.transaction do
|
SyncLog.sync_log("=====check_user_login_is:#{user.login}======")
|
||||||
interactor = Gitea::RegisterInteractor.call({username: user.login, email: user&.mail.present? ? user.mail : "#{user.login}@example.com", password: new_password})
|
|
||||||
if interactor.success?
|
user_mail = user&.mail.present? ? user.mail : "#{user.login}@example.com"
|
||||||
gitea_user = interactor.result
|
# unless user_mail.match(EMAIL_REGEX).present?
|
||||||
result = Gitea::User::GenerateTokenService.new(user.login, new_password).call
|
# user_mail = "#{user.login}@example.com"
|
||||||
user.gitea_token = result['sha1']
|
# end
|
||||||
user.gitea_uid = gitea_user['id']
|
ActiveRecord::Base.transaction do
|
||||||
if user.save!
|
interactor = Gitea::RegisterInteractor.call({username: user.login, email: user_mail, password: new_password})
|
||||||
SyncLog.sync_log("=================create_gitea_user_success_login==#{user.login}")
|
if interactor.success?
|
||||||
|
gitea_user = interactor.result
|
||||||
|
result = Gitea::User::GenerateTokenService.new(user.login, new_password).call
|
||||||
|
user.gitea_token = result['sha1']
|
||||||
|
user.gitea_uid = gitea_user['id']
|
||||||
|
if user.save!
|
||||||
|
SyncLog.sync_log("=================create_gitea_user_success_login==#{user.login}")
|
||||||
|
else
|
||||||
|
SyncLog.sync_log("=================create_gitea_user_success_login==#{user.login}")
|
||||||
|
end
|
||||||
else
|
else
|
||||||
SyncLog.sync_log("=================create_gitea_user_success_login==#{user.login}")
|
SyncLog.sync_log("=============sync_to_user_failed,user_login====#{user.login}")
|
||||||
end
|
end
|
||||||
else
|
|
||||||
SyncLog.sync_log("=============sync_to_user_failed,user_login====#{user.login}")
|
|
||||||
end
|
end
|
||||||
|
rescue => exception
|
||||||
|
SyncLog.sync_log("=================create_gitea_user_has_erros=#{user.login}===#{exception}")
|
||||||
end
|
end
|
||||||
rescue Exception => e
|
|
||||||
SyncLog.sync_log("=================create_gitea_user_has_erros=#{user.login}===#{e}")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
SyncLog.sync_log("=====end_to_check_gitea_user=====")
|
SyncLog.sync_log("=====end_to_check_gitea_user=====")
|
||||||
|
|
|
@ -8,7 +8,7 @@ class CheckMirrorRake
|
||||||
all_projects = Project.select(:id,:identifier,:user_id, :gpid, :forked_count,:is_public).includes(:owner, :repository)
|
all_projects = Project.select(:id,:identifier,:user_id, :gpid, :forked_count,:is_public).includes(:owner, :repository)
|
||||||
all_projects.each do |project|
|
all_projects.each do |project|
|
||||||
SyncLog.sync_log("=====check_project_id:#{project.id}======")
|
SyncLog.sync_log("=====check_project_id:#{project.id}======")
|
||||||
if project&.owner&.login.present? &&
|
if project&.owner&.login.present?
|
||||||
response = Gitea::Repository::Branches::ListService.new(project.owner, project.identifier).call
|
response = Gitea::Repository::Branches::ListService.new(project.owner, project.identifier).call
|
||||||
else
|
else
|
||||||
response = "224444"
|
response = "224444"
|
||||||
|
|
Loading…
Reference in New Issue