update token generation
This commit is contained in:
parent
fab0cc51b3
commit
735687be21
@ -255,8 +255,8 @@ export class User {
|
|||||||
public password: string | null;
|
public password: string | null;
|
||||||
|
|
||||||
@Index({ unique: true })
|
@Index({ unique: true })
|
||||||
@Column('varchar', {
|
@Column('char', {
|
||||||
length: 32, nullable: true, unique: true,
|
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.'
|
comment: 'The native access token of the User. It will be null if the origin of the user is local.'
|
||||||
})
|
})
|
||||||
public token: string | null;
|
public token: string | null;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
import rndstr from 'rndstr';
|
import rndstr from 'rndstr';
|
||||||
|
|
||||||
export default () => `!${rndstr('a-zA-Z0-9', 31)}`;
|
export default () => `0${rndstr('a-zA-Z0-9', 15)}`;
|
||||||
|
@ -1 +1 @@
|
|||||||
export default (token: string) => token.startsWith('!');
|
export default (token: string) => token.startsWith('0');
|
||||||
|
@ -38,7 +38,7 @@ export default define(meta, async (ps, user) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate access token
|
// Generate access token
|
||||||
const accessToken = rndstr('a-zA-Z0-9', 32);
|
const accessToken = '1' + rndstr('a-zA-Z0-9', 15);
|
||||||
|
|
||||||
// Fetch exist access token
|
// Fetch exist access token
|
||||||
const exist = await AccessTokens.findOne({
|
const exist = await AccessTokens.findOne({
|
||||||
|
Loading…
Reference in New Issue
Block a user