1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 18:29:27 +02:00

Add ability to list and revoke token sessions

This commit is contained in:
Chocobozzz 2025-07-30 11:33:07 +02:00
parent a53ed039b8
commit 57caf25611
No known key found for this signature in database
GPG key ID: 583A612D890159BE
40 changed files with 1158 additions and 138 deletions

View file

@ -23,6 +23,12 @@ type TokenInfo = {
refreshToken: string
accessTokenExpiresAt: Date
refreshTokenExpiresAt: Date
loginDevice: string
loginIP: string
loginDate: Date
lastActivityDevice: string
lastActivityIP: string
lastActivityDate: Date
}
export type BypassLogin = {
@ -194,13 +200,21 @@ async function saveToken (
authName = refreshTokenAuthName
}
logger.debug('Saving token ' + token.accessToken + ' for client ' + client.id + ' and user ' + user.id + '.')
logger.debug(`Saving token ${token.accessToken} for client ${client.id} and user ${user.id}.`)
const tokenToCreate = {
accessToken: token.accessToken,
accessTokenExpiresAt: token.accessTokenExpiresAt,
refreshToken: token.refreshToken,
refreshTokenExpiresAt: token.refreshTokenExpiresAt,
...pick(token, [
'accessToken',
'refreshToken',
'accessTokenExpiresAt',
'refreshTokenExpiresAt',
'loginDevice',
'loginIP',
'loginDate',
'lastActivityDate',
'lastActivityDevice',
'lastActivityIP'
]),
authName,
oAuthClientId: client.id,
userId: user.id