后台创建openi关联用户时直接授权,并且修改了生成用户名的规则

dev_partners
Alec Zhou 6 years ago
parent 97c2b1f1f5
commit 451e06dcaa

@ -188,14 +188,13 @@ class OauthController < ApplicationController
break if existing_user.present?
user = User.new(lastname: name, mail: email, mail_notification: email)
user.login = custom_openi_login(login)
user.login = generate_login('m')
user.password = DEFAULT_PASSWORD
user.certification = 1
user.save!
UserExtensions.create!(user_id: user.id, school_id: School.first.id, identity: 4, gender: 0)
UserDayCertification.create!(user_id: user.id, status: 1)
openi = Openi.create!(user_id: user.id, openi_user_id: openi_user_id, avatar_url: avatar_url, login: login, name: name, email: email)
end
end
@ -214,9 +213,10 @@ class OauthController < ApplicationController
####--End-- 获取Openi的授权码access_token以及用户信息。为在openi登录的用户创建相关的educoder用户 ####
private
# 为了保证新创建的用户用户名不与系统中已存在的用户冲突,加上 _openi 后缀
def custom_openi_login(login)
login + '_openi'
# 为新创建的用户随机生成以m为前缀的用户名m表示该用户是用邮箱注册
def generate_login(login_pre)
us = UsersService.new
us.generate_user_login(login_pre)
end
def require_login

Loading…
Cancel
Save