aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/plugins/register-helpers-store.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-28 14:49:03 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-04 16:21:39 +0200
commit4a8d113b9b57d97ff13ad1608798eabca99643e4 (patch)
tree7c6e1ba86bff31680ba6c8ba4bd903b997592269 /server/lib/plugins/register-helpers-store.ts
parent98813e69bccc568eff771cfcaf907ccdd82ce3f1 (diff)
downloadPeerTube-4a8d113b9b57d97ff13ad1608798eabca99643e4.tar.gz
PeerTube-4a8d113b9b57d97ff13ad1608798eabca99643e4.tar.zst
PeerTube-4a8d113b9b57d97ff13ad1608798eabca99643e4.zip
Begin support for external auths
Diffstat (limited to 'server/lib/plugins/register-helpers-store.ts')
-rw-r--r--server/lib/plugins/register-helpers-store.ts42
1 files changed, 19 insertions, 23 deletions
diff --git a/server/lib/plugins/register-helpers-store.ts b/server/lib/plugins/register-helpers-store.ts
index 687974ccf..277f2b687 100644
--- a/server/lib/plugins/register-helpers-store.ts
+++ b/server/lib/plugins/register-helpers-store.ts
@@ -1,31 +1,21 @@
1import { PluginSettingsManager } from '@shared/models/plugins/plugin-settings-manager.model' 1import { logger } from '@server/helpers/logger'
2import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PLAYLIST_PRIVACIES, VIDEO_PRIVACIES } from '@server/initializers/constants'
3import { onExternalUserAuthenticated } from '@server/lib/auth'
2import { PluginModel } from '@server/models/server/plugin' 4import { PluginModel } from '@server/models/server/plugin'
5import { RegisterServerOptions } from '@server/typings/plugins'
6import { PluginPlaylistPrivacyManager } from '@shared/models/plugins/plugin-playlist-privacy-manager.model'
7import { PluginSettingsManager } from '@shared/models/plugins/plugin-settings-manager.model'
3import { PluginStorageManager } from '@shared/models/plugins/plugin-storage-manager.model' 8import { PluginStorageManager } from '@shared/models/plugins/plugin-storage-manager.model'
9import { PluginVideoCategoryManager } from '@shared/models/plugins/plugin-video-category-manager.model'
4import { PluginVideoLanguageManager } from '@shared/models/plugins/plugin-video-language-manager.model' 10import { PluginVideoLanguageManager } from '@shared/models/plugins/plugin-video-language-manager.model'
5import {
6 VIDEO_CATEGORIES,
7 VIDEO_LANGUAGES,
8 VIDEO_LICENCES,
9 VIDEO_PLAYLIST_PRIVACIES,
10 VIDEO_PRIVACIES
11} from '@server/initializers/constants'
12import { PluginVideoLicenceManager } from '@shared/models/plugins/plugin-video-licence-manager.model' 11import { PluginVideoLicenceManager } from '@shared/models/plugins/plugin-video-licence-manager.model'
13import { PluginVideoCategoryManager } from '@shared/models/plugins/plugin-video-category-manager.model' 12import { PluginVideoPrivacyManager } from '@shared/models/plugins/plugin-video-privacy-manager.model'
14import { RegisterServerOptions } from '@server/typings/plugins' 13import { RegisterServerAuthExternalOptions, RegisterServerAuthExternalResult, RegisterServerAuthPassOptions, RegisterServerExternalAuthenticatedResult } from '@shared/models/plugins/register-server-auth.model'
15import { buildPluginHelpers } from './plugin-helpers'
16import { logger } from '@server/helpers/logger'
17import { RegisterServerHookOptions } from '@shared/models/plugins/register-server-hook.model' 14import { RegisterServerHookOptions } from '@shared/models/plugins/register-server-hook.model'
18import { serverHookObject } from '@shared/models/plugins/server-hook.model'
19import { RegisterServerSettingOptions } from '@shared/models/plugins/register-server-setting.model' 15import { RegisterServerSettingOptions } from '@shared/models/plugins/register-server-setting.model'
16import { serverHookObject } from '@shared/models/plugins/server-hook.model'
20import * as express from 'express' 17import * as express from 'express'
21import { PluginVideoPrivacyManager } from '@shared/models/plugins/plugin-video-privacy-manager.model' 18import { buildPluginHelpers } from './plugin-helpers'
22import { PluginPlaylistPrivacyManager } from '@shared/models/plugins/plugin-playlist-privacy-manager.model'
23import {
24 RegisterServerAuthExternalOptions,
25 RegisterServerAuthExternalResult,
26 RegisterServerAuthPassOptions
27} from '@shared/models/plugins/register-server-auth.model'
28import { onExternalAuthPlugin } from '@server/lib/auth'
29 19
30type AlterableVideoConstant = 'language' | 'licence' | 'category' | 'privacy' | 'playlistPrivacy' 20type AlterableVideoConstant = 'language' | 'licence' | 'category' | 'privacy' | 'playlistPrivacy'
31type VideoConstant = { [key in number | string]: string } 21type VideoConstant = { [key in number | string]: string }
@@ -187,8 +177,14 @@ export class RegisterHelpersStore {
187 this.externalAuths.push(options) 177 this.externalAuths.push(options)
188 178
189 return { 179 return {
190 onAuth (options: { username: string, email: string }): void { 180 userAuthenticated (result: RegisterServerExternalAuthenticatedResult): void {
191 onExternalAuthPlugin(self.npmName, options.username, options.email) 181 onExternalUserAuthenticated({
182 npmName: self.npmName,
183 authName: options.authName,
184 authResult: result
185 }).catch(err => {
186 logger.error('Cannot execute onExternalUserAuthenticated.', { npmName: self.npmName, authName: options.authName, err })
187 })
192 } 188 }
193 } as RegisterServerAuthExternalResult 189 } as RegisterServerAuthExternalResult
194 } 190 }