This commit is contained in:
2026-01-17 23:11:08 +08:00
parent d6da542989
commit 7b0b00feff
9 changed files with 95 additions and 184 deletions

View File

@@ -26,12 +26,15 @@ export const addAuth = (app: App) => {
return;
}
if (!token) {
app.throw(401, 'Token is required');
ctx.throw(401, 'Token is required');
}
const user = await User.getOauthUser(token);
console.log('auth user: exists', !user);
if (!user) {
app.throw(401, 'Token is invalid');
ctx.throw(401, 'Token is invalid');
return;
}
console.log(`auth user: ${user.username} (${user.id})`);
const someInfo = getSomeInfoFromReq(ctx);
if (someInfo.isBrowser && !ctx.req?.cookies?.['token']) {
createCookie({ accessToken: token }, ctx);