Merged in feat/SW-1488-unlink-sas-account (pull request #1349)

Implement unlink SAS flow

Approved-by: Joakim Jäderberg
This commit is contained in:
Anton Gunnarsson
2025-02-20 15:09:06 +00:00
parent fc720b1dbc
commit 340f6d1714
22 changed files with 216 additions and 82 deletions

View File

@@ -18,8 +18,11 @@ import type { LangParams, PageArgs, SearchParams } from "@/types/params"
import type { State } from "../sasUtils"
const searchParamsSchema = z.object({
intent: z.enum(["link"]),
intent: z.enum(["link", "unlink"]),
})
type Intent = z.infer<typeof searchParamsSchema>["intent"]
export default async function SASxScandicLoginPage({
searchParams,
params,
@@ -42,11 +45,19 @@ export default async function SASxScandicLoginPage({
const clientId = env.SAS_AUTH_CLIENTID
const sasLoginHostname = env.SAS_AUTH_ENDPOINT
const audience = "eb-partner-api"
// TODO check if this is correct scopes
const scope = encodeURIComponent("openid profile email")
const loginLink = `${sasLoginHostname}/oauth/authorize?response_type=code&client_id=${clientId}&redirect_uri=${redirectUri}&scope=${scope}&state=${urlState}&audience=${audience}`
const intentDescriptions: Record<Intent, string> = {
link: intl.formatMessage({
id: "In order to verify your account linking we will ask you to sign in to your SAS EuroBonus account.",
}),
unlink: intl.formatMessage({
id: "Log in to your SAS Eurobonus account to confirm account unlinking.",
}),
}
return (
<SASModal>
<Redirect url={loginLink} timeout={3000} />
@@ -60,11 +71,7 @@ export default async function SASxScandicLoginPage({
<Title as="h2" level="h1" textTransform="regular">
{intl.formatMessage({ id: "Redirecting you to SAS" })}
</Title>
<Body textAlign="center">
{intl.formatMessage({
id: "In order to verify your account linking we will ask you to sign in to your SAS EuroBonus account.",
})}
</Body>
<Body textAlign="center">{intentDescriptions[parsedParams.intent]}</Body>
<Footnote textAlign="center">
{intl.formatMessage<React.ReactNode>(
{