From a448172952845ebd0f756c19afee9ffc6bc7cafc Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Sun, 29 Mar 2020 23:18:03 +0900 Subject: [PATCH] Fix #6199 (#6201) --- src/server/api/endpoints/auth/accept.ts | 1 + src/server/api/endpoints/i/apps.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/server/api/endpoints/auth/accept.ts b/src/server/api/endpoints/auth/accept.ts index e9281f1236..6cde1a9ecd 100644 --- a/src/server/api/endpoints/auth/accept.ts +++ b/src/server/api/endpoints/auth/accept.ts @@ -60,6 +60,7 @@ export default define(meta, async (ps, user) => { await AccessTokens.save({ id: genId(), createdAt: new Date(), + lastUsedAt: new Date(), appId: session.appId, userId: user.id, token: accessToken, diff --git a/src/server/api/endpoints/i/apps.ts b/src/server/api/endpoints/i/apps.ts index 3b5cd21a79..69958f1ca4 100644 --- a/src/server/api/endpoints/i/apps.ts +++ b/src/server/api/endpoints/i/apps.ts @@ -26,8 +26,8 @@ export default define(meta, async (ps, user) => { switch (ps.sort) { case '+createdAt': query.orderBy('token.createdAt', 'DESC'); break; case '-createdAt': query.orderBy('token.createdAt', 'ASC'); break; - case '+lastUsedAt': query.andWhere('token.lastUsedAt IS NOT NULL').orderBy('token.lastUsedAt', 'DESC'); break; - case '-lastUsedAt': query.andWhere('token.lastUsedAt IS NOT NULL').orderBy('token.lastUsedAt', 'ASC'); break; + case '+lastUsedAt': query.orderBy('token.lastUsedAt', 'DESC'); break; + case '-lastUsedAt': query.orderBy('token.lastUsedAt', 'ASC'); break; default: query.orderBy('token.id', 'ASC'); break; }