mirror of
https://github.com/MisskeyIO/misskey
synced 2024-12-01 00:08:24 +09:00
enhance(api): アクセストークンを作成する際、createdAtをlastUsedAtを揃えるようにして、未使用かどうかを判定できるように
This commit is contained in:
parent
f73a4e1304
commit
2bdcd22ad4
@ -56,11 +56,13 @@ export default define(meta, async (ps, user) => {
|
|||||||
sha256.update(accessToken + app.secret);
|
sha256.update(accessToken + app.secret);
|
||||||
const hash = sha256.digest('hex');
|
const hash = sha256.digest('hex');
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
// Insert access token doc
|
// Insert access token doc
|
||||||
await AccessTokens.save({
|
await AccessTokens.save({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: now,
|
||||||
lastUsedAt: new Date(),
|
lastUsedAt: now,
|
||||||
appId: session.appId,
|
appId: session.appId,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
token: accessToken,
|
token: accessToken,
|
||||||
|
@ -38,11 +38,13 @@ export default define(meta, async (ps, user) => {
|
|||||||
// Generate access token
|
// Generate access token
|
||||||
const accessToken = secureRndstr(32, true);
|
const accessToken = secureRndstr(32, true);
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
|
||||||
// Insert access token doc
|
// Insert access token doc
|
||||||
await AccessTokens.save({
|
await AccessTokens.save({
|
||||||
id: genId(),
|
id: genId(),
|
||||||
createdAt: new Date(),
|
createdAt: now,
|
||||||
lastUsedAt: new Date(),
|
lastUsedAt: now,
|
||||||
session: ps.session,
|
session: ps.session,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
token: accessToken,
|
token: accessToken,
|
||||||
|
Loading…
Reference in New Issue
Block a user