Express.d.ts: normalize session fields case
This commit is contained in:
parent
e4768141bc
commit
f1a8a4ba07
@ -63,7 +63,7 @@ export default class AuthGuard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getProofsForSession(session: Session & Partial<SessionData>): Promise<AuthProof<User>[]> {
|
public async getProofsForSession(session: Session & Partial<SessionData>): Promise<AuthProof<User>[]> {
|
||||||
if (!session.is_authenticated) return [];
|
if (!session.isAuthenticated) return [];
|
||||||
|
|
||||||
const proofs = [];
|
const proofs = [];
|
||||||
for (const method of this.authMethods) {
|
for (const method of this.authMethods) {
|
||||||
@ -80,7 +80,7 @@ export default class AuthGuard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (proofs.length === 0) {
|
if (proofs.length === 0) {
|
||||||
session.is_authenticated = false;
|
session.isAuthenticated = false;
|
||||||
session.persistent = false;
|
session.persistent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ export default class AuthGuard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Login
|
// Login
|
||||||
session.is_authenticated = true;
|
session.isAuthenticated = true;
|
||||||
session.persistent = persistSession;
|
session.persistent = persistSession;
|
||||||
if (onLogin) await onLogin(user);
|
if (onLogin) await onLogin(user);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import {Session, SessionData} from "express-session";
|
|||||||
|
|
||||||
export default class PasswordAuthProof implements AuthProof<User> {
|
export default class PasswordAuthProof implements AuthProof<User> {
|
||||||
public static getProofForSession(session: Session & Partial<SessionData>): PasswordAuthProof | null {
|
public static getProofForSession(session: Session & Partial<SessionData>): PasswordAuthProof | null {
|
||||||
return session.auth_password_proof ? new PasswordAuthProof(session) : null;
|
return session.authPasswordProof ? new PasswordAuthProof(session) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static createAuthorizedProofForRegistration(session: Session): PasswordAuthProof {
|
public static createAuthorizedProofForRegistration(session: Session): PasswordAuthProof {
|
||||||
@ -29,9 +29,9 @@ export default class PasswordAuthProof implements AuthProof<User> {
|
|||||||
|
|
||||||
private constructor(session: Session & Partial<SessionData>) {
|
private constructor(session: Session & Partial<SessionData>) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.authorized = session.auth_password_proof?.authorized || false;
|
this.authorized = session.authPasswordProof?.authorized || false;
|
||||||
this.forRegistration = session.auth_password_proof?.forRegistration || false;
|
this.forRegistration = session.authPasswordProof?.forRegistration || false;
|
||||||
this.userId = session.auth_password_proof?.userId || null;
|
this.userId = session.authPasswordProof?.userId || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getResource(): Promise<User | null> {
|
public async getResource(): Promise<User | null> {
|
||||||
@ -54,7 +54,7 @@ export default class PasswordAuthProof implements AuthProof<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async revoke(): Promise<void> {
|
public async revoke(): Promise<void> {
|
||||||
this.session.auth_password_proof = undefined;
|
this.session.authPasswordProof = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getUserPassword(): Promise<UserPasswordComponent | null> {
|
private async getUserPassword(): Promise<UserPasswordComponent | null> {
|
||||||
@ -74,7 +74,7 @@ export default class PasswordAuthProof implements AuthProof<User> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private save() {
|
private save() {
|
||||||
this.session.auth_password_proof = {
|
this.session.authPasswordProof = {
|
||||||
authorized: this.authorized,
|
authorized: this.authorized,
|
||||||
forRegistration: this.forRegistration,
|
forRegistration: this.forRegistration,
|
||||||
userId: this.userId,
|
userId: this.userId,
|
||||||
|
4
src/types/Express.d.ts
vendored
4
src/types/Express.d.ts
vendored
@ -45,9 +45,9 @@ declare module 'express-session' {
|
|||||||
|
|
||||||
persistent?: boolean;
|
persistent?: boolean;
|
||||||
|
|
||||||
is_authenticated?: boolean;
|
isAuthenticated?: boolean;
|
||||||
|
|
||||||
auth_password_proof?: PasswordAuthProofSessionData;
|
authPasswordProof?: PasswordAuthProofSessionData;
|
||||||
|
|
||||||
csrf?: string;
|
csrf?: string;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user