Skip to content

Commit 336b12f

Browse files
authored
Merge pull request #153 from import-ai/fix/auth
refactor(auth): organize auth providers into subdirectories
2 parents 1145236 + 0367534 commit 336b12f

File tree

7 files changed

+16
-11
lines changed

7 files changed

+16
-11
lines changed

src/auth/auth.module.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import { InternalAuthController } from 'omniboxd/auth/internal.auth.controller';
1515
import { NamespacesModule } from 'omniboxd/namespaces/namespaces.module';
1616
import { GroupsModule } from 'omniboxd/groups/groups.module';
1717
import { PermissionsModule } from 'omniboxd/permissions/permissions.module';
18-
import { WechatService } from 'omniboxd/auth/wechat.service';
19-
import { WechatController } from 'omniboxd/auth/wechat.controller';
20-
import { GoogleService } from 'omniboxd/auth/google.service';
21-
import { GoogleController } from 'omniboxd/auth/google.controller';
18+
import { WechatService } from 'omniboxd/auth/wechat/wechat.service';
19+
import { WechatController } from 'omniboxd/auth/wechat/wechat.controller';
20+
import { GoogleService } from 'omniboxd/auth/google/google.service';
21+
import { GoogleController } from 'omniboxd/auth/google/google.controller';
2222
import { APIKeyModule } from 'omniboxd/api-key/api-key.module';
2323
import { APIKeyAuthGuard } from 'omniboxd/auth/api-key/api-key-auth.guard';
2424
import { CookieAuthGuard } from 'omniboxd/auth/cookie/cookie-auth.guard';

src/auth/google.controller.ts renamed to src/auth/google/google.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Request } from 'express';
22
import { AuthService } from 'omniboxd/auth/auth.service';
3-
import { GoogleService } from 'omniboxd/auth/google.service';
3+
import { GoogleService } from 'omniboxd/auth/google/google.service';
44
import { Req, Get, Body, Controller, Post } from '@nestjs/common';
55
import { Public } from 'omniboxd/auth/decorators/public.auth.decorator';
66
import { SocialController } from 'omniboxd/auth/social.controller';

src/auth/google.service.ts renamed to src/auth/google/google.service.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { SocialService } from 'omniboxd/auth/social.service';
55
import { UserService } from 'omniboxd/user/user.service';
66
import { NamespacesService } from 'omniboxd/namespaces/namespaces.service';
77
import {
8-
Logger,
9-
Injectable,
108
BadRequestException,
9+
Injectable,
10+
Logger,
1111
UnauthorizedException,
1212
} from '@nestjs/common';
1313

@@ -39,6 +39,7 @@ export class GoogleService extends SocialService {
3939
private readonly clientId: string;
4040
private readonly clientSecret: string;
4141
private readonly redirectUri: string;
42+
private readonly googleOAuthAPIUrl: string;
4243

4344
constructor(
4445
private readonly configService: ConfigService,
@@ -57,6 +58,10 @@ export class GoogleService extends SocialService {
5758
'OBB_GOOGLE_REDIRECT_URI',
5859
'',
5960
);
61+
this.googleOAuthAPIUrl = this.configService.get<string>(
62+
'OBB_GOOGLE_OAUTH_API_URL',
63+
'https://oauth2.googleapis.com',
64+
);
6065
}
6166

6267
getGoogleAuthUrl(): string {
@@ -83,7 +88,7 @@ export class GoogleService extends SocialService {
8388
throw new UnauthorizedException('Invalid state identifier');
8489
}
8590

86-
const tokenResponse = await fetch('https://oauth2.googleapis.com/token', {
91+
const tokenResponse = await fetch(`${this.googleOAuthAPIUrl}/token`, {
8792
method: 'POST',
8893
headers: {
8994
'Content-Type': 'application/x-www-form-urlencoded',

src/auth/wechat.controller.ts renamed to src/auth/wechat/wechat.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Request } from 'express';
22
import { Get, Post, Query, Controller, Req } from '@nestjs/common';
33
import { AuthService } from 'omniboxd/auth/auth.service';
4-
import { WechatService } from 'omniboxd/auth/wechat.service';
4+
import { WechatService } from 'omniboxd/auth/wechat/wechat.service';
55
import { SocialController } from 'omniboxd/auth/social.controller';
66
import { Public } from 'omniboxd/auth/decorators/public.auth.decorator';
77
import { UserId } from 'omniboxd/decorators/user-id.decorator';
File renamed without changes.

src/migrations/1755499552000-update-attachment-urls.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class UpdateAttachmentUrls1755499552000 implements MigrationInterface {
2727
// Replace /api/v1/attachments/images/{id} and
2828
// /api/v1/attachments/media/{id} with attachments/{id}
2929
const updatedContent = originalContent.replace(
30-
/\/api\/v1\/attachments\/(images|media)\/([a-zA-Z0-9\._-]+)/g,
30+
/\/api\/v1\/attachments\/(images|media)\/([a-zA-Z0-9._-]+)/g,
3131
'attachments/$2',
3232
);
3333

src/migrations/1755504936756-scan-resource-attachments.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class ScanResourceAttachments1755504936756
2828

2929
// Find all attachment references in the format: attachments/{id}
3030
const attachmentMatches = content.match(
31-
/attachments\/([a-zA-Z0-9\._-]+)/g,
31+
/attachments\/([a-zA-Z0-9._-]+)/g,
3232
);
3333

3434
for (const match of attachmentMatches || []) {

0 commit comments

Comments
 (0)