|
|
|
@ -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
|
|
|
|
|