Skip to content

Commit cd988d4

Browse files
committed
fix: ci lint error and resolve merge conflicts
1 parent 8bad6db commit cd988d4

5 files changed

Lines changed: 32 additions & 18 deletions

File tree

src/app.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { IndexOptimizationModule } from './database/index-optimization/index-opt
1212
import { RateLimitingModule } from './rate-limiting/rate-limiting.module';
1313
import { QuotaGuard } from './rate-limiting/guards/quota.guard';
1414
import { getDatabaseConfig } from './config/database.config';
15+
import { GlobalAuthGuard } from './auth/guards/global-auth.guard';
1516
import { loadFeatureFlags } from './config/feature-flags.config';
1617
import { SessionModule } from './session/session.module';
1718
import { DebuggingModule } from './debugging/debugging.module';
@@ -76,7 +77,7 @@ const featureFlags = loadFeatureFlags();
7677
? [
7778
{
7879
provide: APP_GUARD,
79-
useClass: require('./auth/guards/global-auth.guard').GlobalAuthGuard,
80+
useClass: GlobalAuthGuard,
8081
},
8182
]
8283
: []),

src/auth/auth.module.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ import { SocialAuthController } from './controllers/social-auth.controller';
3939
ServiceAuthGuard,
4040
GlobalAuthGuard,
4141
],
42-
exports: [PassportModule, JwtModule, AuthService, JwtAuthGuard, ServiceAuthGuard, GlobalAuthGuard],
42+
exports: [
43+
PassportModule,
44+
JwtModule,
45+
AuthService,
46+
JwtAuthGuard,
47+
ServiceAuthGuard,
48+
GlobalAuthGuard,
49+
],
4350
GoogleStrategy,
4451
GitHubStrategy,
4552
SocialAuthService,

src/auth/auth.service.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export class AuthService {
4040
decoded = this.jwtService.verify(refreshToken, {
4141
secret: process.env.JWT_REFRESH_SECRET || 'default-refresh-secret',
4242
});
43+
} catch {
4344
} catch (_e) {
4445
throw new UnauthorizedException('Invalid or expired refresh token');
4546
}
@@ -109,21 +110,23 @@ export class AuthService {
109110
const payload = { sub: user.id, email: user.email, role: user.role };
110111
const refreshJti = uuidv4();
111112

112-
const [accessToken, refreshToken] = await Promise.all([
113-
this.jwtService.signAsync(payload as any, {
113+
const accessToken = await this.jwtService.signAsync(
114+
payload as any,
115+
{
114116
secret: process.env.JWT_SECRET || 'default-jwt-secret',
115117
expiresIn: (process.env.JWT_EXPIRES_IN || '15m') as any,
116-
} as any),
118+
} as any,
117119
}),
118-
this.jwtService.signAsync(
119-
{ ...payload, jti: refreshJti } as any,
120-
{
121-
secret: process.env.JWT_REFRESH_SECRET || 'default-refresh-secret',
122-
expiresIn: (process.env.JWT_REFRESH_EXPIRES_IN || '7d') as any,
123-
} as any,
120+
);
121+
122+
const refreshToken = await this.jwtService.signAsync(
123+
{ ...payload, jti: refreshJti } as any,
124+
{
125+
secret: process.env.JWT_REFRESH_SECRET || 'default-refresh-secret',
126+
expiresIn: (process.env.JWT_REFRESH_EXPIRES_IN || '7d') as any,
127+
} as any,
124128
},
125-
),
126-
]);
129+
);
127130

128131
return {
129132
accessToken,

src/auth/guards/global-auth.guard.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, ExecutionContext, Inject, UnauthorizedException } from '@nestjs/common';
1+
import { Injectable, ExecutionContext, UnauthorizedException } from '@nestjs/common';
22
import { CanActivate } from '@nestjs/common/interfaces';
33
import { Reflector } from '@nestjs/core';
44
import { JwtAuthGuard } from './jwt-auth.guard';
@@ -29,15 +29,15 @@ export class GlobalAuthGuard implements CanActivate {
2929
try {
3030
const result = (await this.jwtGuard.canActivate(context)) as boolean;
3131
if (result) return true;
32-
} catch (e) {
32+
} catch {
3333
// continue to try service guard
3434
}
3535

3636
// Try service token
3737
try {
3838
const result = (await this.serviceGuard.canActivate(context)) as boolean;
3939
if (result) return true;
40-
} catch (e) {
40+
} catch {
4141
// both failed
4242
}
4343

src/auth/guards/service-auth.guard.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ export class ServiceAuthGuard implements CanActivate {
2727

2828
// Basic validation: service claim and allowed list
2929
const serviceName = (payload as any).service as string | undefined;
30-
const allowed = (process.env.SERVICE_ALLOW_LIST || '').split(',').map((s) => s.trim()).filter(Boolean);
30+
const allowed = (process.env.SERVICE_ALLOW_LIST || '')
31+
.split(',')
32+
.map((s) => s.trim())
33+
.filter(Boolean);
3134

3235
if (!serviceName) throw new UnauthorizedException('Invalid service token');
3336
if (allowed.length > 0 && !allowed.includes(serviceName)) {
@@ -37,7 +40,7 @@ export class ServiceAuthGuard implements CanActivate {
3740
// attach service identity for downstream usage
3841
(req as any).serviceIdentity = { name: serviceName, claims: payload };
3942
return true;
40-
} catch (e) {
43+
} catch {
4144
throw new UnauthorizedException('Invalid service token');
4245
}
4346
}

0 commit comments

Comments
 (0)