Skip to content

Commit

Permalink
fix(github): fix github enterprise authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
lucabertelli committed Oct 24, 2023
1 parent a7e7285 commit 360ffa2
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions controllers/auth/read.auth.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ router.get('/github/callback', async (req, res, next) => {

logger.debug('----> new UserInfo')

let accessToken = null

fetch(
tokenURL +
'?client_id=' +
Expand All @@ -107,26 +109,23 @@ router.get('/github/callback', async (req, res, next) => {
}
}
)
.then((res) => res.json())
.then((json) => {
.then((respToken) => respToken.json())
.then((jsonToken) => {
logger.debug('5')
logger.debug(json)
req.session.github_token = json.access_token
logger.debug('6')
logger.debug(req.session.github_token)
accessToken = jsonToken.access_token
})
.catch((err) => console.log(err))
.then(() => {
fetch(userProfileURL, {
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: 'Bearer ' + req.session.github_token
Authorization: 'Bearer ' + accessToken
}
})
.then((res) => res.json())
.then((respUser) => respUser.json())
.then((json) => {
logger.debug('7')
logger.debug(clientSecret)
userInfo.id = json.id
userInfo.displayName = json.name
userInfo.username = json.login
Expand Down

0 comments on commit 360ffa2

Please sign in to comment.