Remove Email Regex

This commit is contained in:
sylor_huang@126.com 2020-07-17 17:04:10 +08:00
parent ed02967a40
commit 375e1fee83
1 changed files with 5 additions and 4 deletions

View File

@ -7,14 +7,15 @@ class CheckGiteaUser
all_users = User.select(:id, :gitea_token, :gitea_uid, :mail, :type,:login,:platform).where(type: "User", gitea_token: [nil, ""], gitea_uid: [nil, ""])
if all_users.present?
new_password = "12345678"
# EMAIL_REGEX = /^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9_\-.]+(\.[a-zA-Z0-9_-]+)+$/i
all_users.each do |user|
begin
SyncLog.sync_log("=====check_user_login_is:#{user.login}======")
EMAIL_REGEX = /^[a-zA-Z0-9_\-.]+@[a-zA-Z0-9_\-.]+(\.[a-zA-Z0-9_-]+)+$/
user_mail = user&.mail.present? ? user.mail : "#{user.login}@example.com"
unless user_mail.match(EMAIL_REGEX).present?
user_mail = "#{user.login}@example.com"
end
# unless user_mail.match(EMAIL_REGEX).present?
# user_mail = "#{user.login}@example.com"
# end
ActiveRecord::Base.transaction do
interactor = Gitea::RegisterInteractor.call({username: user.login, email: user_mail, password: new_password})
if interactor.success?