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:
Joakim Jäderberg
2025-10-28 09:51:30 +00:00
parent 4a6c64f921
commit a4f1a55e56
15 changed files with 105 additions and 90 deletions

View File

@@ -7,8 +7,8 @@ import { dt } from "@scandic-hotels/common/dt"
import { env } from "@/env/server"
export async function getSession() {
return getIronSession<{
async function internalGetSession() {
return await getIronSession<{
access_token: string
refresh_token: string | undefined
expires_at: string
@@ -18,7 +18,17 @@ export async function getSession() {
})
}
export async function createSession({
export async function getSocialSession() {
const session = await internalGetSession()
if (!session?.access_token) {
return null
}
return session
}
export async function createSocialSession({
access_token,
refresh_token,
expires_in,
@@ -27,7 +37,7 @@ export async function createSession({
expires_in: number
refresh_token?: string
}) {
const session = await getSession()
const session = await internalGetSession()
session.access_token = access_token
session.refresh_token = refresh_token
@@ -38,8 +48,8 @@ export async function createSession({
await session.save()
}
export async function destroySession() {
const session = await getSession()
export async function destroySocialSession() {
const session = await internalGetSession()
if (!session) return
session.destroy()