Commit 138d7376 authored by Sparkf's avatar Sparkf 🏙️
Browse files

fix the login error when user has different firstname and lastname between...

fix the login error when user has different firstname and lastname between sharelatex and oauth2 provider
parent ed469670
Loading
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -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: {
+3 −5
Original line number Diff line number Diff line
@@ -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) {