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
79 lines
1.2 KiB
TypeScript
79 lines
1.2 KiB
TypeScript
import { NextResponse } from "next/server"
|
|
|
|
export function ok<T>(data: T) {
|
|
return NextResponse.json(data, {
|
|
status: 200,
|
|
statusText: "Ok",
|
|
})
|
|
}
|
|
|
|
export function noContent() {
|
|
return NextResponse.json(undefined, {
|
|
status: 204,
|
|
statusText: "No Content",
|
|
})
|
|
}
|
|
|
|
export function badRequest(cause?: unknown) {
|
|
const resInit = {
|
|
status: 400,
|
|
statusText: "Bad request",
|
|
}
|
|
|
|
return NextResponse.json(
|
|
{
|
|
cause,
|
|
},
|
|
resInit
|
|
)
|
|
}
|
|
|
|
export function notFound(cause?: unknown) {
|
|
const resInit = {
|
|
status: 404,
|
|
statusText: "Not found",
|
|
}
|
|
|
|
return NextResponse.json(
|
|
{
|
|
cause,
|
|
},
|
|
resInit
|
|
)
|
|
}
|
|
|
|
export function internalServerError(cause?: unknown) {
|
|
const resInit = {
|
|
status: 500,
|
|
statusText: "Internal Server Error",
|
|
}
|
|
|
|
return NextResponse.json(
|
|
{
|
|
cause,
|
|
},
|
|
resInit
|
|
)
|
|
}
|
|
|
|
export function serviceUnavailable(cause?: unknown) {
|
|
const resInit = {
|
|
status: 503,
|
|
statusText: "Service Unavailable",
|
|
}
|
|
|
|
return NextResponse.json(
|
|
{
|
|
cause,
|
|
},
|
|
resInit
|
|
)
|
|
}
|
|
|
|
export function response<T>(data: T, status: number, statusText: string) {
|
|
return NextResponse.json(data, {
|
|
status,
|
|
statusText,
|
|
})
|
|
}
|