summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2019-04-08 20:29:52 +0900
committersyuilo <syuilotan@yahoo.co.jp>2019-04-08 20:29:52 +0900
commit735687be21b08a11bf167663b9336a56eeb05313 (patch)
treeca3dae42affa74e83e62d22471fb17cd098816f6 /src
parentFix (diff)
downloadsharkey-735687be21b08a11bf167663b9336a56eeb05313.tar.gz
sharkey-735687be21b08a11bf167663b9336a56eeb05313.tar.bz2
sharkey-735687be21b08a11bf167663b9336a56eeb05313.zip
update token generation
Diffstat (limited to 'src')
-rw-r--r--src/models/entities/user.ts4
-rw-r--r--src/server/api/common/generate-native-user-token.ts2
-rw-r--r--src/server/api/common/is-native-token.ts2
-rw-r--r--src/server/api/endpoints/auth/accept.ts2
4 files changed, 5 insertions, 5 deletions
diff --git a/src/models/entities/user.ts b/src/models/entities/user.ts
index 1ef98cadc2..0a2878c0c9 100644
--- a/src/models/entities/user.ts
+++ b/src/models/entities/user.ts
@@ -255,8 +255,8 @@ export class User {
public password: string | null;
@Index({ unique: true })
- @Column('varchar', {
- length: 32, nullable: true, unique: true,
+ @Column('char', {
+ length: 16, nullable: true, unique: true,
comment: 'The native access token of the User. It will be null if the origin of the user is local.'
})
public token: string | null;
diff --git a/src/server/api/common/generate-native-user-token.ts b/src/server/api/common/generate-native-user-token.ts
index 92f8a3a0e8..9d44885630 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 () => `!${rndstr('a-zA-Z0-9', 31)}`;
+export default () => `0${rndstr('a-zA-Z0-9', 15)}`;
diff --git a/src/server/api/common/is-native-token.ts b/src/server/api/common/is-native-token.ts
index 6afbc99ab5..22af84aad2 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('!');
+export default (token: string) => token.startsWith('0');
diff --git a/src/server/api/endpoints/auth/accept.ts b/src/server/api/endpoints/auth/accept.ts
index 21a78011dc..0baa6b111c 100644
--- a/src/server/api/endpoints/auth/accept.ts
+++ b/src/server/api/endpoints/auth/accept.ts
@@ -38,7 +38,7 @@ export default define(meta, async (ps, user) => {
}
// Generate access token
- const accessToken = rndstr('a-zA-Z0-9', 32);
+ const accessToken = '1' + rndstr('a-zA-Z0-9', 15);
// Fetch exist access token
const exist = await AccessTokens.findOne({