Fix formatting
This commit is contained in:
@@ -28,8 +28,11 @@ function scryptAsync(
|
||||
): Promise<Buffer> {
|
||||
return new Promise((resolve, reject) => {
|
||||
scrypt(password, salt, keylen, options, (err, derivedKey) => {
|
||||
if (err) reject(err);
|
||||
else resolve(derivedKey);
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(derivedKey);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -114,7 +114,9 @@ export class AuthService {
|
||||
|
||||
private extractCookieToken(request: ExpressRequest): string | null {
|
||||
const cookies = request.get("Cookie");
|
||||
if (!cookies) return null;
|
||||
if (!cookies) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (const cookie of cookies.split(";")) {
|
||||
const [name, ...valueParts] = cookie.trim().split("=");
|
||||
@@ -245,7 +247,9 @@ export class AuthService {
|
||||
extractToken(request: ExpressRequest): string | null {
|
||||
// Try Authorization header first
|
||||
const token = parseAuthorizationHeader(request.get("Authorization"));
|
||||
if (token) return token;
|
||||
if (token) {
|
||||
return token;
|
||||
}
|
||||
|
||||
// Try cookie
|
||||
return this.extractCookieToken(request);
|
||||
|
||||
@@ -75,7 +75,9 @@ export class InMemoryAuthStore implements AuthStore {
|
||||
|
||||
async getSession(tokenId: TokenId): Promise<SessionData | null> {
|
||||
const session = this.sessions.get(tokenId);
|
||||
if (!session) return null;
|
||||
if (!session) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check expiration
|
||||
if (new Date() > session.expiresAt) {
|
||||
@@ -110,7 +112,9 @@ export class InMemoryAuthStore implements AuthStore {
|
||||
|
||||
async getUserByEmail(email: string): Promise<User | null> {
|
||||
const userId = this.usersByEmail.get(email.toLowerCase());
|
||||
if (!userId) return null;
|
||||
if (!userId) {
|
||||
return null;
|
||||
}
|
||||
return this.users.get(userId) ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,9 @@ function hashToken(token: string): string {
|
||||
|
||||
// Parse token from Authorization header
|
||||
function parseAuthorizationHeader(header: string | undefined): string | null {
|
||||
if (!header) return null;
|
||||
if (!header) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const parts = header.split(" ");
|
||||
if (parts.length !== 2 || parts[0].toLowerCase() !== "bearer") {
|
||||
|
||||
Reference in New Issue
Block a user