Rework user types: create AuthenticatedUser and AnonymousUser class

Both are subclasses of an abstract User class which contains almost everything
interesting.
This commit is contained in:
2026-01-17 17:45:36 -06:00
parent 350bf7c865
commit d921679058
9 changed files with 102 additions and 62 deletions

View File

@@ -64,17 +64,17 @@ export const tokenLifetimes: Record<TokenType, number> = {
};
// Import here to avoid circular dependency at module load time
import { AnonymousUser, type MaybeUser } from "../user";
import type { User } from "../user";
// Session wrapper class providing a consistent interface for handlers.
// Always present on Call (never null), but may represent an anonymous session.
export class Session {
constructor(
private readonly data: SessionData | null,
private readonly user: MaybeUser,
private readonly user: User,
) {}
getUser(): MaybeUser {
getUser(): User {
return this.user;
}
@@ -83,7 +83,7 @@ export class Session {
}
isAuthenticated(): boolean {
return this.user !== AnonymousUser;
return !this.user.isAnonymous();
}
get tokenId(): string | undefined {