release: WRNexusJS 0.5.10
This commit is contained in:
@@ -12,9 +12,16 @@ function wantsJson(ctx: Context): boolean {
|
||||
return accept.includes("application/json") && !accept.includes("text/html");
|
||||
}
|
||||
|
||||
export function authSession(engine: AuthEngine): Middleware {
|
||||
export interface AuthSessionOptions {
|
||||
/** Optional shared SSO cookie containing an AuthEngine session id. */
|
||||
cookieName?: string;
|
||||
}
|
||||
|
||||
export function authSession(engine: AuthEngine, options: AuthSessionOptions = {}): Middleware {
|
||||
return async (ctx, next) => {
|
||||
const sessionId = ctx.session.get<string>(AUTH_SESSION_KEY);
|
||||
const sessionId =
|
||||
(options.cookieName ? ctx.cookies.get(options.cookieName) : undefined) ??
|
||||
ctx.session.get<string>(AUTH_SESSION_KEY);
|
||||
if (!sessionId) {
|
||||
ctx.user = null;
|
||||
ctx.locals.authUser = null;
|
||||
|
||||
Reference in New Issue
Block a user