wip: redirect

This commit is contained in:
William Ryder 2023-09-21 01:40:05 +02:00
parent d75f2ec5ed
commit 8a1a0d757e
2 changed files with 13 additions and 2 deletions

View File

@ -35,6 +35,7 @@ import {
bankIdCheckUrl,
bankIdSessionUrl,
bankIdCallbackUrl,
redirectLocomotive,
apiUrls,
} from './routes'
import parse from '@skolplattformen/curriculum'
@ -336,8 +337,15 @@ export class ApiAdmentum extends EventEmitter implements Api {
this.isLoggedIn = true
this.personalNumber = personalNumber
console.log('callback url', bankIdCallbackUrl(sessionId));
const callbackResponse = await this.followRedirects(bankIdCallbackUrl(sessionId));
const locomotiveUrl = redirectLocomotive(sessionId)
const response = await this.fetch('follow-locomotive', locomotiveUrl, {
method: 'GET',
redirect: 'follow',
});
console.log('locomotive response', response)
console.log('locomotive url', locomotiveUrl);
const callbackResponse = await this.followRedirects(locomotiveUrl);
console.log('final response:', callbackResponse);
//const testChildren = await this.getChildren()
//console.log('test children', testChildren)

View File

@ -47,6 +47,9 @@ export const apiUrls = {
export const bankIdCheckUrl = (sessionId: string) =>
`https://login.grandid.com/?sessionid=${sessionId}&collect=1`
export const redirectLocomotive = (sessionId: string) =>
`https://login.grandid.com/?sessionid=${sessionId}`
export const bankIdSessionUrl = (returnUrl: string) =>
`https://auth.admentum.se/larande${returnUrl ? `?next=${returnUrl}` : ''}`