mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-23 10:16:32 -05:00
Move ProviderEnum and PassportProfile to web/auth/utils.ts
These two are directly related with auth stuff and seem to fit much better there. Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
parent
4e7c82dc3b
commit
5852b45bdd
6 changed files with 30 additions and 31 deletions
|
@ -15,33 +15,9 @@ import {
|
||||||
} from 'sequelize-typescript'
|
} from 'sequelize-typescript'
|
||||||
import { generateAvatarURL } from '../letter-avatars'
|
import { generateAvatarURL } from '../letter-avatars'
|
||||||
import { logger } from '../logger'
|
import { logger } from '../logger'
|
||||||
|
import { PassportProfile, ProviderEnum } from '../web/auth/utils'
|
||||||
import { Note } from './note'
|
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 {
|
export class PhotoProfile {
|
||||||
name: string
|
name: string
|
||||||
photo: string
|
photo: string
|
||||||
|
|
|
@ -11,7 +11,7 @@ import { History } from './history'
|
||||||
import { logger } from './logger'
|
import { logger } from './logger'
|
||||||
import { Author, Note, Revision, User } from './models'
|
import { Author, Note, Revision, User } from './models'
|
||||||
import { NoteAuthorship } from './models/note'
|
import { NoteAuthorship } from './models/note'
|
||||||
import { PhotoProfile, PassportProfile } from './models/user'
|
import { PhotoProfile } from './models/user'
|
||||||
import { EditorSocketIOServer } from './ot/editor-socketio-server'
|
import { EditorSocketIOServer } from './ot/editor-socketio-server'
|
||||||
import { mapToObject } from './utils'
|
import { mapToObject } from './utils'
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { InternalOAuthError, Strategy as OAuth2Strategy } from 'passport-oauth2'
|
import { InternalOAuthError, Strategy as OAuth2Strategy } from 'passport-oauth2'
|
||||||
import { config } from '../../../config'
|
import { config } from '../../../config'
|
||||||
import { PassportProfile, ProviderEnum } from '../../../models/user'
|
import { PassportProfile, ProviderEnum } from '../utils'
|
||||||
|
|
||||||
function extractProfileAttribute (data, path: string): string {
|
function extractProfileAttribute (data, path: string): string {
|
||||||
// can handle stuff like `attrs[0].name`
|
// can handle stuff like `attrs[0].name`
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Profile } from 'passport'
|
import { Profile } from 'passport'
|
||||||
import { User } from '../../models'
|
|
||||||
import { logger } from '../../logger'
|
import { logger } from '../../logger'
|
||||||
|
import { User } from '../../models'
|
||||||
|
|
||||||
export function passportGeneralCallback (
|
export function passportGeneralCallback (
|
||||||
accessToken: string,
|
accessToken: string,
|
||||||
|
@ -48,3 +48,26 @@ export function passportGeneralCallback (
|
||||||
return done(err, undefined)
|
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 }[];
|
||||||
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ import path from 'path'
|
||||||
import { config } from '../../config'
|
import { config } from '../../config'
|
||||||
import { errors } from '../../errors'
|
import { errors } from '../../errors'
|
||||||
import { logger } from '../../logger'
|
import { logger } from '../../logger'
|
||||||
import { Note, User } from '../../models'
|
import { Note } from '../../models'
|
||||||
import { PassportProfile, PhotoProfile } from '../../models/user'
|
import { PhotoProfile } from '../../models/user'
|
||||||
|
|
||||||
export function newNote (req, res: Response, body: string | null): void {
|
export function newNote (req, res: Response, body: string | null): void {
|
||||||
let owner = null
|
let owner = null
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { Note, User } from '../models'
|
||||||
import { logger } from '../logger'
|
import { logger } from '../logger'
|
||||||
import { generateAvatar } from '../letter-avatars'
|
import { generateAvatar } from '../letter-avatars'
|
||||||
import { config } from '../config'
|
import { config } from '../config'
|
||||||
import { PassportProfile, PhotoProfile } from '../models/user'
|
import { PhotoProfile } from '../models/user'
|
||||||
|
|
||||||
const UserRouter = Router()
|
const UserRouter = Router()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue