mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-23 02:17:40 -07:00
enhance(api): アクセストークンを作成する際、createdAtをlastUsedAtを揃えるようにして、未使用かどうかを判定できるように
This commit is contained in:
parent
6c5e2ab4ac
commit
dad630f716
2 changed files with 8 additions and 4 deletions
|
@ -56,11 +56,13 @@ export default define(meta, async (ps, user) => {
|
|||
sha256.update(accessToken + app.secret);
|
||||
const hash = sha256.digest('hex');
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// Insert access token doc
|
||||
await AccessTokens.save({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
lastUsedAt: new Date(),
|
||||
createdAt: now,
|
||||
lastUsedAt: now,
|
||||
appId: session.appId,
|
||||
userId: user.id,
|
||||
token: accessToken,
|
||||
|
|
|
@ -38,11 +38,13 @@ export default define(meta, async (ps, user) => {
|
|||
// Generate access token
|
||||
const accessToken = secureRndstr(32, true);
|
||||
|
||||
const now = new Date();
|
||||
|
||||
// Insert access token doc
|
||||
await AccessTokens.save({
|
||||
id: genId(),
|
||||
createdAt: new Date(),
|
||||
lastUsedAt: new Date(),
|
||||
createdAt: now,
|
||||
lastUsedAt: now,
|
||||
session: ps.session,
|
||||
userId: user.id,
|
||||
token: accessToken,
|
||||
|
|
Loading…
Reference in a new issue