Skip to content

Commit 2b389d4

Browse files
committed
feat: 优化版本等信息获取 鉴权逻辑
1 parent 30a5e5f commit 2b389d4

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

REGISTRATION_CONTROL.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ async getConfig() {
4343
}
4444
```
4545

46-
- 路径:`GET /api/v1/system/config`
46+
- 路径:`GET /api/v1/system/open/config`
4747
- 权限:公开接口,无需认证
4848
- 返回:`{ allowRegistration: boolean }`
4949

@@ -82,7 +82,7 @@ OPERATION_NOT_ALLOWED: 6, // 操作不被允许
8282
```typescript
8383
export const getSystemConfig = () => {
8484
return request.get<unknown, { code: number; msg: string; data: { allowRegistration: boolean } }>(
85-
'/api/v1/system/config'
85+
'/api/v1/system/open/config'
8686
);
8787
};
8888
```
@@ -207,7 +207,7 @@ pnpm dev
207207

208208
```bash
209209
# 1. 获取系统配置
210-
curl http://localhost:3000/api/v1/system/config
210+
curl http://localhost:3000/api/v1/system/open/config
211211

212212
# 预期响应(允许注册):
213213
# {

apps/server/src/controllers/v1/system.controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { UserInfoDto } from '@aimo/dto';
1414
export class SystemController {
1515
constructor(private gitHubReleaseService: GitHubReleaseService) {}
1616

17-
@Get('/version')
17+
@Get('/open/version')
1818
async getVersion(@CurrentUser() user: UserInfoDto) {
1919
// 需要登录后才能访问,返回服务端版本号
2020
const packageJson = await import('../../../package.json', { with: { type: 'json' } });
@@ -27,7 +27,7 @@ export class SystemController {
2727
* Get latest app versions from GitHub releases
2828
* Public endpoint - no authentication required
2929
*/
30-
@Get('/app-versions')
30+
@Get('/open/app-versions')
3131
async getAppVersions() {
3232
try {
3333
const versions = await this.gitHubReleaseService.getAllVersions();
@@ -45,7 +45,7 @@ export class SystemController {
4545
* Get public system configuration
4646
* Public endpoint - no authentication required
4747
*/
48-
@Get('/config')
48+
@Get('/open/config')
4949
async getConfig() {
5050
return ResponseUtility.success({
5151
allowRegistration: config.auth.allowRegistration,

apps/server/src/middlewares/auth-handler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const AUTH_EXCLUDED_PATHS = [
1919
'/api/v1/memos/ba',
2020
'/api/v1/attachments/ba',
2121
'/api/v1/debug/ba',
22+
'/api/v1/system/open',
2223
];
2324

2425
/**

apps/web/src/api/system.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import request from '../utils/request';
66
*/
77
export const getVersion = () => {
88
return request.get<unknown, { code: number; msg: string; data: { version: string } }>(
9-
'/api/v1/system/version'
9+
'/api/v1/system/open/version'
1010
);
1111
};
1212

@@ -16,7 +16,7 @@ export const getVersion = () => {
1616
*/
1717
export const getAppVersions = () => {
1818
return request.get<unknown, { code: number; msg: string; data: AllVersionsResponseDto }>(
19-
'/api/v1/system/app-versions'
19+
'/api/v1/system/open/app-versions'
2020
);
2121
};
2222

@@ -26,6 +26,6 @@ export const getAppVersions = () => {
2626
*/
2727
export const getSystemConfig = () => {
2828
return request.get<unknown, { code: number; msg: string; data: { allowRegistration: boolean } }>(
29-
'/api/v1/system/config'
29+
'/api/v1/system/open/config'
3030
);
3131
};

0 commit comments

Comments
 (0)