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

@@ -18,7 +18,7 @@ import type {
} from "./auth/store";
import { generateToken, hashToken } from "./auth/token";
import type { SessionData, TokenId } from "./auth/types";
import { User, type UserId } from "./user";
import { AuthenticatedUser, type User, type UserId } from "./user";
// Connection configuration
const connectionConfig = {
@@ -367,7 +367,7 @@ class PostgresAuthStore implements AuthStore {
// Helper to convert database row to User object
private rowToUser(row: Selectable<UsersTable>): User {
return new User({
return new AuthenticatedUser({
id: row.id,
email: row.email,
displayName: row.display_name ?? undefined,