From 2bdcd22ad44aed94eb406f788f1546d73fcdf73e Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 4 Aug 2020 23:09:48 +0900 Subject: [PATCH] =?UTF-8?q?enhance(api):=20=E3=82=A2=E3=82=AF=E3=82=BB?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=83=BC=E3=82=AF=E3=83=B3=E3=82=92=E4=BD=9C?= =?UTF-8?q?=E6=88=90=E3=81=99=E3=82=8B=E9=9A=9B=E3=80=81createdAt=E3=82=92?= =?UTF-8?q?lastUsedAt=E3=82=92=E6=8F=83=E3=81=88=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=97=E3=81=A6=E3=80=81=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E3=81=8B=E3=81=A9=E3=81=86=E3=81=8B=E3=82=92=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/api/endpoints/auth/accept.ts | 6 ++++-- src/server/api/endpoints/miauth/gen-token.ts | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/server/api/endpoints/auth/accept.ts b/src/server/api/endpoints/auth/accept.ts index 6cde1a9ec..e98242a3c 100644 --- a/src/server/api/endpoints/auth/accept.ts +++ b/src/server/api/endpoints/auth/accept.ts @@ -56,11 +56,13 @@ export default define(meta, async (ps, user) => { sha256.update(accessToken + app.secret); const hash = sha256.digest('hex'); + const now = new Date(); + // Insert access token doc await AccessTokens.save({ id: genId(), - createdAt: new Date(), - lastUsedAt: new Date(), + createdAt: now, + lastUsedAt: now, appId: session.appId, userId: user.id, token: accessToken, diff --git a/src/server/api/endpoints/miauth/gen-token.ts b/src/server/api/endpoints/miauth/gen-token.ts index 6476e79d7..a5fa19400 100644 --- a/src/server/api/endpoints/miauth/gen-token.ts +++ b/src/server/api/endpoints/miauth/gen-token.ts @@ -38,11 +38,13 @@ export default define(meta, async (ps, user) => { // Generate access token const accessToken = secureRndstr(32, true); + const now = new Date(); + // Insert access token doc await AccessTokens.save({ id: genId(), - createdAt: new Date(), - lastUsedAt: new Date(), + createdAt: now, + lastUsedAt: now, session: ps.session, userId: user.id, token: accessToken,