1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Cache user token

This commit is contained in:
Chocobozzz 2018-09-20 11:31:48 +02:00
parent 91411dba92
commit f201a74992
No known key found for this signature in database
GPG key ID: 583A612D890159BE
7 changed files with 79 additions and 19 deletions

View file

@ -1,10 +1,23 @@
import { AllowNull, BelongsTo, Column, CreatedAt, ForeignKey, Model, Scopes, Table, UpdatedAt } from 'sequelize-typescript'
import {
AfterDelete,
AfterUpdate,
AllowNull,
BelongsTo,
Column,
CreatedAt,
ForeignKey,
Model,
Scopes,
Table,
UpdatedAt
} from 'sequelize-typescript'
import { logger } from '../../helpers/logger'
import { UserModel } from '../account/user'
import { OAuthClientModel } from './oauth-client'
import { Transaction } from 'sequelize'
import { AccountModel } from '../account/account'
import { ActorModel } from '../activitypub/actor'
import { clearCacheByToken } from '../../lib/oauth-model'
export type OAuthTokenInfo = {
refreshToken: string
@ -112,6 +125,12 @@ export class OAuthTokenModel extends Model<OAuthTokenModel> {
})
OAuthClients: OAuthClientModel[]
@AfterUpdate
@AfterDelete
static removeTokenCache (token: OAuthTokenModel) {
return clearCacheByToken(token.accessToken)
}
static getByRefreshTokenAndPopulateClient (refreshToken: string) {
const query = {
where: {