From f43db2f46ee50bacb402a6ef42d768694c2bc9a8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 12 Mar 2021 15:20:46 +0100 Subject: Refactor auth flow Reimplement some node-oauth2-server methods to remove hacky code needed by our external login workflow --- server/models/account/user-notification-setting.ts | 4 ++-- server/models/account/user.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'server/models/account') diff --git a/server/models/account/user-notification-setting.ts b/server/models/account/user-notification-setting.ts index de1501299..138051528 100644 --- a/server/models/account/user-notification-setting.ts +++ b/server/models/account/user-notification-setting.ts @@ -12,10 +12,10 @@ import { Table, UpdatedAt } from 'sequelize-typescript' +import { TokensCache } from '@server/lib/auth/tokens-cache' import { MNotificationSettingFormattable } from '@server/types/models' import { UserNotificationSetting, UserNotificationSettingValue } from '../../../shared/models/users/user-notification-setting.model' import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications' -import { clearCacheByUserId } from '../../lib/oauth-model' import { throwIfNotValid } from '../utils' import { UserModel } from './user' @@ -195,7 +195,7 @@ export class UserNotificationSettingModel extends Model { @AfterUpdate @AfterDestroy static removeTokenCache (instance: UserNotificationSettingModel) { - return clearCacheByUserId(instance.userId) + return TokensCache.Instance.clearCacheByUserId(instance.userId) } toFormattedJSON (this: MNotificationSettingFormattable): UserNotificationSetting { diff --git a/server/models/account/user.ts b/server/models/account/user.ts index c1f22b76a..a7a65c489 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -21,6 +21,7 @@ import { Table, UpdatedAt } from 'sequelize-typescript' +import { TokensCache } from '@server/lib/auth/tokens-cache' import { MMyUserFormattable, MUser, @@ -58,7 +59,6 @@ import { } from '../../helpers/custom-validators/users' import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto' import { DEFAULT_USER_THEME_NAME, NSFW_POLICY_TYPES } from '../../initializers/constants' -import { clearCacheByUserId } from '../../lib/oauth-model' import { getThemeOrDefault } from '../../lib/plugins/theme-utils' import { ActorModel } from '../activitypub/actor' import { ActorFollowModel } from '../activitypub/actor-follow' @@ -411,7 +411,7 @@ export class UserModel extends Model { @AfterUpdate @AfterDestroy static removeTokenCache (instance: UserModel) { - return clearCacheByUserId(instance.id) + return TokensCache.Instance.clearCacheByUserId(instance.id) } static countTotal () { -- cgit v1.2.3