|
|
@@ -6,6 +6,7 @@ import { ErrorSchema } from '../../../utils/errorHandler'
|
|
|
import { AppDataSource } from '../../../data-source'
|
|
|
import { AuthContext } from '../../../types/context'
|
|
|
import { UserSchema } from '@/server/modules/users/user.schema'
|
|
|
+import { parseWithAwait } from '@/server/utils/parseWithAwait'
|
|
|
|
|
|
const userService = new UserService(AppDataSource)
|
|
|
const authService = new AuthService(userService)
|
|
|
@@ -74,7 +75,8 @@ const app = new OpenAPIHono<AuthContext>().openapi(loginRoute, async (c) => {
|
|
|
try {
|
|
|
const { username, password } = c.req.valid('json')
|
|
|
const result = await authService.login(username, password)
|
|
|
- return c.json(result, 200)
|
|
|
+
|
|
|
+ return c.json(await parseWithAwait(TokenResponseSchema, result), 200)
|
|
|
} catch (error) {
|
|
|
// 认证相关错误返回401
|
|
|
if (error instanceof Error &&
|