forked from Trustie/forgeplus
FIX 主动同步头歌账号到gitea平台,防止前端进行弹框
This commit is contained in:
parent
5c3ebb9946
commit
c7d99d14f8
|
|
@ -16,6 +16,7 @@ class ApplicationController < ActionController::Base
|
|||
before_action :check_sign
|
||||
before_action :user_setup
|
||||
#before_action :check_account
|
||||
before_action :check_gitea_account
|
||||
|
||||
# TODO
|
||||
# check sql query time
|
||||
|
|
@ -278,6 +279,42 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
# TODO
|
||||
# 临时处理弹框同步gitea账号问题
|
||||
def check_gitea_account
|
||||
return unless current_user.logged?
|
||||
|
||||
if !current_user.has_gitea_user? || (current_user.has_gitea_user? && !current_user.is_sync_pwd)
|
||||
begin
|
||||
email = current_user.mail
|
||||
|
||||
if email.blank?
|
||||
user_extension = current_user.user_extension
|
||||
email_identifier =
|
||||
if user_extension
|
||||
if user_extension.identity == 'student'
|
||||
current_user.student_id
|
||||
elsif user_extension.identity == 'teacher'
|
||||
current_user.staff_id
|
||||
else
|
||||
nil
|
||||
end
|
||||
else
|
||||
nil
|
||||
end
|
||||
|
||||
email = email_identifier.blank? ? "#{current_user.login}@qq.com" : "#{email_identifier}@qq.com"
|
||||
current_user.update_column(:mail, email)
|
||||
end
|
||||
|
||||
create_gitea_user!(current_user, current_user.login, email, 'zq123456')
|
||||
rescue => e
|
||||
Rails.logger.info "@@主动检测并同步gitea账号错误: #{e.message}"
|
||||
next
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# 系统全局认证(暂时隐藏试用申请的判断)
|
||||
def check_auth
|
||||
# day_cer = UserDayCertification.find_by(user_id: current_user.id)
|
||||
|
|
|
|||
|
|
@ -785,6 +785,10 @@ class User < Owner
|
|||
def set_lastname
|
||||
self.lastname = self.nickname if changes[:nickname].present?
|
||||
end
|
||||
|
||||
def has_gitea_user?
|
||||
self.gitea_token.present? && self.gitea_uid.present?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue