Merged in feature/curity-social-login (pull request #2963)

feat(SW-3541): Do social login after login to SAS

* feat(auth): wip social login via curity

* Setup social login auth flow

* Merge branch 'master' of bitbucket.org:scandic-swap/web into feature/curity-social-login

* Added support for getting scandic tokens and refresh them

* feat: Enhance social login and session management with auto-refresh and improved error handling

* Merge branch 'master' of bitbucket.org:scandic-swap/web into feature/curity-social-login

* wrap layout in suspense

* revert app/layout.tsx

* fix import

* cleanup

* merge

* merge

* dont pass client_secret in the url to curity

* add state validation when doing social login through /authorize

* remove debug logging


Approved-by: Anton Gunnarsson
This commit is contained in:
Joakim Jäderberg
2025-10-16 12:47:12 +00:00
parent 1850cfd20d
commit 291310e841
24 changed files with 827 additions and 84 deletions

View File

@@ -2,6 +2,8 @@ import NextAuth, { type NextAuthConfig } from "next-auth"
import Auth0Provider from "next-auth/providers/auth0"
import { createLogger } from "@scandic-hotels/common/logger/createLogger"
import { safeTry } from "@scandic-hotels/common/utils/safeTry"
import { getEuroBonusProfileData } from "@scandic-hotels/trpc/routers/partners/sas/getEuroBonusProfile"
import { env } from "@/env/server"
@@ -60,9 +62,17 @@ const config: NextAuthConfig = {
if (!expiresAt) {
throw new Error("AuthError: Missing expiry time")
}
const [eurobonusProfile, error] = await safeTry(
getEuroBonusProfileData({ accessToken, loginType: "sas" })
)
if (error) {
authLogger.error("Failed to fetch EuroBonus profile", error)
}
return {
...params.token,
isLinked: eurobonusProfile?.linkStatus === "LINKED",
loginType: "sas",
access_token: accessToken,
expires_at: expiresAt,
@@ -79,6 +89,7 @@ const config: NextAuthConfig = {
? {
...session.user,
id: token.sub,
isLinked: token.isLinked,
}
: undefined,
token: {