게임 세션의 원자적 발급과 추적 상한 및 회수를 보강한다
This commit is contained in:
1 parent
6755f09ee7
commit
eeda225429
9 files changed
+399
-44
No files matched your search
@@ -15,9 +15,13 @@ export const procedure = t.procedure.use(async ({ ctx, path, getRawInput, next }
|
||||
if (path === 'auth.login' && typeof input.username === 'string' && input.username.length <= 64) {
|
||||
return `login:${input.username.trim().toLocaleLowerCase('en-US')}`;
|
||||
}
|
||||
if (path.startsWith('account.') && typeof input.sessionToken === 'string' && input.sessionToken.length <= 256) {
|
||||
if (
|
||||
(path.startsWith('account.') || path === 'auth.issueGameSession') &&
|
||||
typeof input.sessionToken === 'string' &&
|
||||
input.sessionToken.length <= 256
|
||||
) {
|
||||
const session = await ctx.sessions.getSession(input.sessionToken);
|
||||
if (session) return `account:${session.userId}`;
|
||||
if (session) return `${path === 'auth.issueGameSession' ? 'game-session' : 'account'}:${session.userId}`;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user