Merged in feat/SW-1266-implement-sas-link-account-endpoint (pull request #1332)
Implement API call to link SAS account * Add endpoint to actually link SAS account linking * add logging of error * Refactor tocDate to getCurrentDateWithoutTime Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -117,7 +117,7 @@ export async function GET(
|
||||
/** Record<string, any> is next-auth typings */
|
||||
const params: Record<string, any> = {
|
||||
ui_locales: context.params.lang,
|
||||
scope: ["openid", "profile", "booking"],
|
||||
scope: ["openid", "profile", "booking", "profile_link"],
|
||||
/**
|
||||
* The `acr_values` param is used to make Curity display the proper login
|
||||
* page for Scandic. Without the parameter Curity presents some choices
|
||||
|
||||
@@ -141,16 +141,30 @@ async function handleLinkAccount({
|
||||
if (!res || error) {
|
||||
console.error("[SAS] link account error", error)
|
||||
return {
|
||||
url: `/${lang}/sas-x-scandic/error?errorCode=link_error`,
|
||||
url: `/${lang}/sas-x-scandic/error`,
|
||||
}
|
||||
}
|
||||
|
||||
console.log("[SAS] link account response", res)
|
||||
switch (res.linkingState) {
|
||||
case "alreadyLinked":
|
||||
return {
|
||||
url: `/${lang}/sas-x-scandic/error?errorCode=alreadyLinked`,
|
||||
type: "replace",
|
||||
}
|
||||
case "linked":
|
||||
return {
|
||||
url: `/${lang}/sas-x-scandic/link/success`,
|
||||
type: "replace",
|
||||
}
|
||||
case "dateOfBirthMismatch":
|
||||
return {
|
||||
url: `/${lang}/sas-x-scandic/error?errorCode=dateOfBirthMismatch`,
|
||||
type: "replace",
|
||||
}
|
||||
case "error":
|
||||
return {
|
||||
url: `/${lang}/sas-x-scandic/error`,
|
||||
type: "replace",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user