Fix formatting

This commit is contained in:
2026-01-10 08:51:20 -06:00
parent 17ea6ba02d
commit 6c0895de07
5 changed files with 29 additions and 10 deletions

View File

@@ -28,8 +28,11 @@ function scryptAsync(
): Promise<Buffer> { ): Promise<Buffer> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
scrypt(password, salt, keylen, options, (err, derivedKey) => { scrypt(password, salt, keylen, options, (err, derivedKey) => {
if (err) reject(err); if (err) {
else resolve(derivedKey); reject(err);
} else {
resolve(derivedKey);
}
}); });
}); });
} }

View File

@@ -114,7 +114,9 @@ export class AuthService {
private extractCookieToken(request: ExpressRequest): string | null { private extractCookieToken(request: ExpressRequest): string | null {
const cookies = request.get("Cookie"); const cookies = request.get("Cookie");
if (!cookies) return null; if (!cookies) {
return null;
}
for (const cookie of cookies.split(";")) { for (const cookie of cookies.split(";")) {
const [name, ...valueParts] = cookie.trim().split("="); const [name, ...valueParts] = cookie.trim().split("=");
@@ -245,7 +247,9 @@ export class AuthService {
extractToken(request: ExpressRequest): string | null { extractToken(request: ExpressRequest): string | null {
// Try Authorization header first // Try Authorization header first
const token = parseAuthorizationHeader(request.get("Authorization")); const token = parseAuthorizationHeader(request.get("Authorization"));
if (token) return token; if (token) {
return token;
}
// Try cookie // Try cookie
return this.extractCookieToken(request); return this.extractCookieToken(request);

View File

@@ -75,7 +75,9 @@ export class InMemoryAuthStore implements AuthStore {
async getSession(tokenId: TokenId): Promise<SessionData | null> { async getSession(tokenId: TokenId): Promise<SessionData | null> {
const session = this.sessions.get(tokenId); const session = this.sessions.get(tokenId);
if (!session) return null; if (!session) {
return null;
}
// Check expiration // Check expiration
if (new Date() > session.expiresAt) { if (new Date() > session.expiresAt) {
@@ -110,7 +112,9 @@ export class InMemoryAuthStore implements AuthStore {
async getUserByEmail(email: string): Promise<User | null> { async getUserByEmail(email: string): Promise<User | null> {
const userId = this.usersByEmail.get(email.toLowerCase()); const userId = this.usersByEmail.get(email.toLowerCase());
if (!userId) return null; if (!userId) {
return null;
}
return this.users.get(userId) ?? null; return this.users.get(userId) ?? null;
} }

View File

@@ -19,7 +19,9 @@ function hashToken(token: string): string {
// Parse token from Authorization header // Parse token from Authorization header
function parseAuthorizationHeader(header: string | undefined): string | null { function parseAuthorizationHeader(header: string | undefined): string | null {
if (!header) return null; if (!header) {
return null;
}
const parts = header.split(" "); const parts = header.split(" ");
if (parts.length !== 2 || parts[0].toLowerCase() !== "bearer") { if (parts.length !== 2 || parts[0].toLowerCase() !== "bearer") {

View File

@@ -241,7 +241,9 @@ class PostgresAuthStore implements AuthStore {
.where("expires_at", ">", new Date()) .where("expires_at", ">", new Date())
.executeTakeFirst(); .executeTakeFirst();
if (!row) return null; if (!row) {
return null;
}
return { return {
tokenId: row.token_id, tokenId: row.token_id,
@@ -290,7 +292,9 @@ class PostgresAuthStore implements AuthStore {
.where(sql`LOWER(email)`, "=", email.toLowerCase()) .where(sql`LOWER(email)`, "=", email.toLowerCase())
.executeTakeFirst(); .executeTakeFirst();
if (!row) return null; if (!row) {
return null;
}
return this.rowToUser(row); return this.rowToUser(row);
} }
@@ -301,7 +305,9 @@ class PostgresAuthStore implements AuthStore {
.where("id", "=", userId) .where("id", "=", userId)
.executeTakeFirst(); .executeTakeFirst();
if (!row) return null; if (!row) {
return null;
}
return this.rowToUser(row); return this.rowToUser(row);
} }