まあ resolve #2 かな
This commit is contained in:
parent
d20ac2c507
commit
41f40dd2c2
15 changed files with 100 additions and 40 deletions
13
src/functions/gen-token.ts
Normal file
13
src/functions/gen-token.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import rndstr from 'rndstr';
|
||||
import { UsedToken } from '../models/entities/usedToken';
|
||||
import { UsedTokens } from '../models';
|
||||
|
||||
export const genToken = async (): Promise<string> => {
|
||||
let used: UsedToken | undefined = undefined;
|
||||
let token: string;
|
||||
do {
|
||||
token = rndstr(32);
|
||||
used = await UsedTokens.findOne({ token });
|
||||
} while (used !== undefined);
|
||||
return token;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue