diff --git a/src/lib/models/user.ts b/src/lib/models/user.ts index 5e906ff48..d9ec8098a 100644 --- a/src/lib/models/user.ts +++ b/src/lib/models/user.ts @@ -15,33 +15,9 @@ import { } from 'sequelize-typescript' import { generateAvatarURL } from '../letter-avatars' import { logger } from '../logger' +import { PassportProfile, ProviderEnum } from '../web/auth/utils' import { Note } from './note' -// core - -export enum ProviderEnum { - facebook = 'facebook', - twitter = 'twitter', - github = 'github', - gitlab = 'gitlab', - dropbox = 'dropbox', - google = 'google', - ldap = 'ldap', - oauth2 = 'oauth2', - saml = 'saml', -} - -export type PassportProfile = { - id: string; - username: string; - displayName: string; - emails: string[]; - avatarUrl: string; - profileUrl: string; - provider: ProviderEnum; - photos: { value: string }[]; -} - export class PhotoProfile { name: string photo: string diff --git a/src/lib/realtime.ts b/src/lib/realtime.ts index bee9b0774..d16e474ee 100644 --- a/src/lib/realtime.ts +++ b/src/lib/realtime.ts @@ -11,7 +11,7 @@ import { History } from './history' import { logger } from './logger' import { Author, Note, Revision, User } from './models' import { NoteAuthorship } from './models/note' -import { PhotoProfile, PassportProfile } from './models/user' +import { PhotoProfile } from './models/user' import { EditorSocketIOServer } from './ot/editor-socketio-server' import { mapToObject } from './utils' diff --git a/src/lib/web/auth/oauth2/oauth2-custom-strategy.ts b/src/lib/web/auth/oauth2/oauth2-custom-strategy.ts index 191e521cb..a502efbb5 100644 --- a/src/lib/web/auth/oauth2/oauth2-custom-strategy.ts +++ b/src/lib/web/auth/oauth2/oauth2-custom-strategy.ts @@ -1,6 +1,6 @@ import { InternalOAuthError, Strategy as OAuth2Strategy } from 'passport-oauth2' import { config } from '../../../config' -import { PassportProfile, ProviderEnum } from '../../../models/user' +import { PassportProfile, ProviderEnum } from '../utils' function extractProfileAttribute (data, path: string): string { // can handle stuff like `attrs[0].name` diff --git a/src/lib/web/auth/utils.ts b/src/lib/web/auth/utils.ts index 025b21478..4c957ef5c 100644 --- a/src/lib/web/auth/utils.ts +++ b/src/lib/web/auth/utils.ts @@ -1,6 +1,6 @@ import { Profile } from 'passport' -import { User } from '../../models' import { logger } from '../../logger' +import { User } from '../../models' export function passportGeneralCallback ( accessToken: string, @@ -48,3 +48,26 @@ export function passportGeneralCallback ( return done(err, undefined) }) } + +export enum ProviderEnum { + facebook = 'facebook', + twitter = 'twitter', + github = 'github', + gitlab = 'gitlab', + dropbox = 'dropbox', + google = 'google', + ldap = 'ldap', + oauth2 = 'oauth2', + saml = 'saml', +} + +export type PassportProfile = { + id: string; + username: string; + displayName: string; + emails: string[]; + avatarUrl: string; + profileUrl: string; + provider: ProviderEnum; + photos: { value: string }[]; +} diff --git a/src/lib/web/note/util.ts b/src/lib/web/note/util.ts index 51fd9bca2..ca54c1780 100644 --- a/src/lib/web/note/util.ts +++ b/src/lib/web/note/util.ts @@ -5,8 +5,8 @@ import path from 'path' import { config } from '../../config' import { errors } from '../../errors' import { logger } from '../../logger' -import { Note, User } from '../../models' -import { PassportProfile, PhotoProfile } from '../../models/user' +import { Note } from '../../models' +import { PhotoProfile } from '../../models/user' export function newNote (req, res: Response, body: string | null): void { let owner = null diff --git a/src/lib/web/userRouter.ts b/src/lib/web/userRouter.ts index 93f38f7e5..6abb77b62 100644 --- a/src/lib/web/userRouter.ts +++ b/src/lib/web/userRouter.ts @@ -6,7 +6,7 @@ import { Note, User } from '../models' import { logger } from '../logger' import { generateAvatar } from '../letter-avatars' import { config } from '../config' -import { PassportProfile, PhotoProfile } from '../models/user' +import { PhotoProfile } from '../models/user' const UserRouter = Router()