Merged in feat/sas-otp-error-handling (pull request #1272)
Feat/sas otp error handling * Improve error handling for SAS OTP * Remove failing and deprecated test Approved-by: Joakim Jäderberg
This commit is contained in:
@@ -82,13 +82,23 @@ export async function GET(
|
||||
const [data, error] = await safeTry(
|
||||
serverClient().partner.sas.requestOtp({})
|
||||
)
|
||||
// status: 'SENT' => OK
|
||||
if (!data || error) {
|
||||
//TODO: Check what error we get
|
||||
console.error("[SAS] Failed to request OTP", error)
|
||||
redirect(`/${lang}/sas-x-scandic/error`)
|
||||
}
|
||||
|
||||
switch (data.status) {
|
||||
case "ABUSED":
|
||||
redirect(`/${params.lang}/sas-x-scandic/error?errorCode=tooManyCodes`)
|
||||
case "NOTSENT":
|
||||
redirect(`/${params.lang}/sas-x-scandic/error`)
|
||||
case "NULL":
|
||||
case "RETRY":
|
||||
case "EXPIRED":
|
||||
// These errors should never happen for request, but according to the API spec they can
|
||||
throw new Error(`Unhandled request OTP status ${data.status}`)
|
||||
}
|
||||
|
||||
console.log("[SAS] Request OTP response", data)
|
||||
|
||||
const otpUrl = new URL(
|
||||
|
||||
Reference in New Issue
Block a user