Merged in feat/basic-user (pull request #3135)
feat(SW-3610): Get basic user from api * feat(SW-3610): Get basic user from api * . * Optional profileid Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -3,6 +3,7 @@ import { headers } from "next/headers"
|
||||
import { dt } from "@scandic-hotels/common/dt"
|
||||
import { createContext } from "@scandic-hotels/trpc/context"
|
||||
import { getEuroBonusProfileData } from "@scandic-hotels/trpc/routers/partners/sas/getEuroBonusProfile"
|
||||
import { getBasicUser } from "@scandic-hotels/trpc/routers/user/utils/getBasicUser"
|
||||
import { getVerifiedUser } from "@scandic-hotels/trpc/routers/user/utils/getVerifiedUser"
|
||||
import {
|
||||
appServerClient,
|
||||
@@ -57,6 +58,19 @@ export async function createAppContext() {
|
||||
includeExtendedPartnerData: input?.withExtendedPartnerData,
|
||||
})
|
||||
|
||||
return user ?? null
|
||||
},
|
||||
getScandicBasicUser: async () => {
|
||||
const session = await getSocialSession()
|
||||
if (!session) return null
|
||||
|
||||
const user = await getBasicUser({
|
||||
token: {
|
||||
expires_at: dt(session.expires_at).unix() * 1000,
|
||||
access_token: session.access_token,
|
||||
},
|
||||
})
|
||||
|
||||
return user ?? null
|
||||
},
|
||||
})
|
||||
|
||||
@@ -6,6 +6,7 @@ import { Lang } from "@scandic-hotels/common/constants/language"
|
||||
import { login } from "@scandic-hotels/common/constants/routes/handleAuth"
|
||||
import { createLogger } from "@scandic-hotels/common/logger/createLogger"
|
||||
import { createContext } from "@scandic-hotels/trpc/context"
|
||||
import { getBasicUser } from "@scandic-hotels/trpc/routers/user/utils/getBasicUser"
|
||||
import { getVerifiedUser } from "@scandic-hotels/trpc/routers/user/utils/getVerifiedUser"
|
||||
import {
|
||||
appServerClient,
|
||||
@@ -85,6 +86,19 @@ export async function createAppContext() {
|
||||
includeExtendedPartnerData: input?.withExtendedPartnerData,
|
||||
})
|
||||
|
||||
return user ?? null
|
||||
},
|
||||
getScandicBasicUser: async () => {
|
||||
const session = await getUserSession()
|
||||
if (!session) return null
|
||||
|
||||
const user = await getBasicUser({
|
||||
token: {
|
||||
expires_at: session.token.expires_at ?? 0,
|
||||
access_token: session.token.access_token,
|
||||
},
|
||||
})
|
||||
|
||||
return user ?? null
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user