fix the login error when user has different firstname and lastname between sharelatex and oauth2 provider

This commit is contained in:
sparkcyf 2022-06-12 01:36:59 +08:00
parent ed4696706b
commit 138d73760c
2 changed files with 10 additions and 12 deletions

View File

@ -316,13 +316,13 @@ const AuthenticationController = {
params.append('redirect_uri', (process.env.SHARELATEX_SITE_URL + "/oauth/callback"))
json_body = {
"grant_type": "authorization_code",
client_id: process.env.OAUTH_CLIENT_ID,
client_secret: process.env.OAUTH_CLIENT_SECRET,
"code": code,
redirect_uri: (process.env.SHARELATEX_SITE_URL + "/oauth/callback"),
}
// json_body = {
// "grant_type": "authorization_code",
// client_id: process.env.OAUTH_CLIENT_ID,
// client_secret: process.env.OAUTH_CLIENT_SECRET,
// "code": code,
// redirect_uri: (process.env.SHARELATEX_SITE_URL + "/oauth/callback"),
// }
axios.post(process.env.OAUTH_ACCESS_URL, params, {
headers: {

View File

@ -55,9 +55,7 @@ const AuthenticationManager = {
createUserIfNotExist(oauth_user, callback) {
const query = {
//name: ZHANG San
email: oauth_user.email,
first_name: oauth_user.given_name, //San
last_name: oauth_user.family_name //Zhang
email: oauth_user.email
};
User.findOne(query, (error, user) => {
if ((!user || !user.hashedPassword)) {
@ -66,8 +64,8 @@ const AuthenticationManager = {
const userRegHand = require('../User/UserRegistrationHandler.js')
userRegHand.registerNewUser({
email: query.email,
first_name: query.first_name,
last_name: query.last_name,
first_name: oauth_user.given_name,
last_name: oauth_user.family_name,
password: pass
},
function (error, user) {