From bce8c5a315330e6500faae37f559a5d114df69d3 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 16 Apr 2019 01:05:21 +0900 Subject: [PATCH] Refactor --- src/server/api/common/generate-native-user-token.ts | 2 +- src/server/api/common/is-native-token.ts | 2 +- src/server/api/endpoints/auth/accept.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/server/api/common/generate-native-user-token.ts b/src/server/api/common/generate-native-user-token.ts index 9d44885630..a372221a0a 100644 --- a/src/server/api/common/generate-native-user-token.ts +++ b/src/server/api/common/generate-native-user-token.ts @@ -1,3 +1,3 @@ import rndstr from 'rndstr'; -export default () => `0${rndstr('a-zA-Z0-9', 15)}`; +export default () => rndstr('a-zA-Z0-9', 16); diff --git a/src/server/api/common/is-native-token.ts b/src/server/api/common/is-native-token.ts index 22af84aad2..2833c570c8 100644 --- a/src/server/api/common/is-native-token.ts +++ b/src/server/api/common/is-native-token.ts @@ -1 +1 @@ -export default (token: string) => token.startsWith('0'); +export default (token: string) => token.length === 16; diff --git a/src/server/api/endpoints/auth/accept.ts b/src/server/api/endpoints/auth/accept.ts index a584e7267b..be7f3b5468 100644 --- a/src/server/api/endpoints/auth/accept.ts +++ b/src/server/api/endpoints/auth/accept.ts @@ -39,7 +39,7 @@ export default define(meta, async (ps, user) => { } // Generate access token - const accessToken = '1' + rndstr('a-zA-Z0-9', 15); + const accessToken = rndstr('a-zA-Z0-9', 32); // Fetch exist access token const exist = await AccessTokens.findOne({