|
|
@@ -3,6 +3,8 @@ import { AuthService } from '../modules/auth/auth.service';
|
|
|
import { UserService } from '../modules/users/user.service';
|
|
|
import { AppDataSource } from '../data-source';
|
|
|
import { AuthContext } from '../types/context';
|
|
|
+import { parseWithAwait } from '../utils/parseWithAwait';
|
|
|
+import { UserSchema } from '../modules/users/user.schema';
|
|
|
|
|
|
export async function authMiddleware(c: Context<AuthContext>, next: Next) {
|
|
|
try {
|
|
|
@@ -26,7 +28,7 @@ export async function authMiddleware(c: Context<AuthContext>, next: Next) {
|
|
|
return c.json({ message: 'User not found' }, 401);
|
|
|
}
|
|
|
|
|
|
- c.set('user', user);
|
|
|
+ c.set('user', await parseWithAwait(UserSchema, user));
|
|
|
c.set('token', token);
|
|
|
await next();
|
|
|
} catch (error) {
|