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:
parent
91411dba92
commit
f201a74992
7 changed files with 79 additions and 19 deletions
|
@ -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: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue