Skip to content

Commit

Permalink
MMT-3962: Added console log statements to help debug issue with login. (
Browse files Browse the repository at this point in the history
#1336)

* MMT-3962: Added console log statements to help debug issue with login.
  • Loading branch information
cgokey authored Jan 23, 2025
1 parent 756d4b7 commit 7d10ed7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions serverless/src/samlCallback/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,28 @@ const getLaunchpadToken = (cookieString) => {
* @param {Object} event Details about the HTTP request that it received
*/
const samlCallback = async (event) => {
console.log('***** in saml callback')
const { body, headers } = event
const { Cookie: headerCookie } = headers
const { mmtHost } = getApplicationConfig()
console.log('***** in saml callback mmthost=', mmtHost)

const params = new URLSearchParams(body)
const path = params.get('RelayState')
console.log('***** in saml callback path=', path)

const launchpadToken = getLaunchpadToken(headerCookie)
console.log('***** in saml callback token=', launchpadToken)

const edlProfile = await fetchEdlProfile(launchpadToken)
console.log('***** in saml callback profile=', edlProfile)

// Create JWT with launchpad token and edl profile
const jwt = createJwt(launchpadToken, edlProfile)
console.log('***** in saml callback jwt=', jwt)

const location = `${mmtHost}/auth-callback?target=${encodeURIComponent(path)}`
console.log('***** in saml callback location=', location)

const response = {
statusCode: 303,
Expand All @@ -53,6 +60,7 @@ const samlCallback = async (event) => {
Location: location
}
}
console.log('***** in saml callback response=', response)

return response
}
Expand Down
2 changes: 1 addition & 1 deletion serverless/src/utils/__tests__/fetchEdlProfile.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe('fetchEdlProfile', () => {
expect(error.message).toEqual('Error calling EDL')
})

expect(consoleMock).toHaveBeenCalledTimes(1)
expect(consoleMock).toHaveBeenCalledTimes(3)
expect(consoleMock).toHaveBeenCalledWith('fetchEdlProfile Error: ', new Error('Error calling EDL'))

expect(token).toEqual(undefined)
Expand Down
3 changes: 3 additions & 0 deletions serverless/src/utils/fetchEdlProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ const fetchEdlProfile = async (launchpadToken) => {
}

const { host } = getEdlConfig()
console.log('***** in saml callback edl host=', host)

const clientToken = await fetchEdlClientToken()
console.log('***** in saml callback clientToken=', clientToken)

return fetch(`${host}/api/nams/edl_user`, {
body: `token=${launchpadToken}`,
Expand All @@ -29,6 +31,7 @@ const fetchEdlProfile = async (launchpadToken) => {
})
.then((response) => response.json())
.then((profile) => {
console.log('***** in saml callback profile', profile)
const {
first_name: firstName,
last_name: lastName
Expand Down

0 comments on commit 7d10ed7

Please sign in to comment.