Merged in feat/SW-3549-handle-unlinked-account (pull request #3019)
fix(SW-3549): update social session management functions for clarity and consistency * refactor(SW-3549): rename session management functions for clarity and consistency * merge Approved-by: Hrishikesh Vaipurkar
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
||||
} from "@scandic-hotels/trpc/serverClient"
|
||||
|
||||
import { auth } from "@/auth"
|
||||
import { getSession } from "@/auth/scandic/session"
|
||||
import { getSocialSession } from "@/auth/scandic/session"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
@@ -29,7 +29,7 @@ export async function createAppContext() {
|
||||
return session
|
||||
},
|
||||
getScandicUserToken: async () => {
|
||||
const session = await getSession()
|
||||
const session = await getSocialSession()
|
||||
return session?.access_token ?? null
|
||||
},
|
||||
getUserPointsBalance: async () => {
|
||||
@@ -46,17 +46,17 @@ export async function createAppContext() {
|
||||
return euroBonusProfile.points.total
|
||||
},
|
||||
getScandicUser: async () => {
|
||||
const session = await getSession()
|
||||
const session = await getSocialSession()
|
||||
if (!session) return null
|
||||
|
||||
// The getSession will either return empty object or session object, hence we need to validate if the object is empty or not
|
||||
if (!session?.access_token) return null
|
||||
|
||||
return await getVerifiedUser({
|
||||
const user = await getVerifiedUser({
|
||||
token: {
|
||||
expires_at: dt(session.expires_at).unix() * 1000,
|
||||
access_token: session.access_token,
|
||||
},
|
||||
})
|
||||
|
||||
return user ?? null
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user