diff options
author | Chocobozzz <me@florianbigard.com> | 2020-04-28 14:49:03 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-05-04 16:21:39 +0200 |
commit | 4a8d113b9b57d97ff13ad1608798eabca99643e4 (patch) | |
tree | 7c6e1ba86bff31680ba6c8ba4bd903b997592269 /server/lib/plugins/register-helpers-store.ts | |
parent | 98813e69bccc568eff771cfcaf907ccdd82ce3f1 (diff) | |
download | PeerTube-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.ts | 42 |
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 @@ | |||
1 | import { PluginSettingsManager } from '@shared/models/plugins/plugin-settings-manager.model' | 1 | import { logger } from '@server/helpers/logger' |
2 | import { VIDEO_CATEGORIES, VIDEO_LANGUAGES, VIDEO_LICENCES, VIDEO_PLAYLIST_PRIVACIES, VIDEO_PRIVACIES } from '@server/initializers/constants' | ||
3 | import { onExternalUserAuthenticated } from '@server/lib/auth' | ||
2 | import { PluginModel } from '@server/models/server/plugin' | 4 | import { PluginModel } from '@server/models/server/plugin' |
5 | import { RegisterServerOptions } from '@server/typings/plugins' | ||
6 | import { PluginPlaylistPrivacyManager } from '@shared/models/plugins/plugin-playlist-privacy-manager.model' | ||
7 | import { PluginSettingsManager } from '@shared/models/plugins/plugin-settings-manager.model' | ||
3 | import { PluginStorageManager } from '@shared/models/plugins/plugin-storage-manager.model' | 8 | import { PluginStorageManager } from '@shared/models/plugins/plugin-storage-manager.model' |
9 | import { PluginVideoCategoryManager } from '@shared/models/plugins/plugin-video-category-manager.model' | ||
4 | import { PluginVideoLanguageManager } from '@shared/models/plugins/plugin-video-language-manager.model' | 10 | import { PluginVideoLanguageManager } from '@shared/models/plugins/plugin-video-language-manager.model' |
5 | import { | ||
6 | VIDEO_CATEGORIES, | ||
7 | VIDEO_LANGUAGES, | ||
8 | VIDEO_LICENCES, | ||
9 | VIDEO_PLAYLIST_PRIVACIES, | ||
10 | VIDEO_PRIVACIES | ||
11 | } from '@server/initializers/constants' | ||
12 | import { PluginVideoLicenceManager } from '@shared/models/plugins/plugin-video-licence-manager.model' | 11 | import { PluginVideoLicenceManager } from '@shared/models/plugins/plugin-video-licence-manager.model' |
13 | import { PluginVideoCategoryManager } from '@shared/models/plugins/plugin-video-category-manager.model' | 12 | import { PluginVideoPrivacyManager } from '@shared/models/plugins/plugin-video-privacy-manager.model' |
14 | import { RegisterServerOptions } from '@server/typings/plugins' | 13 | import { RegisterServerAuthExternalOptions, RegisterServerAuthExternalResult, RegisterServerAuthPassOptions, RegisterServerExternalAuthenticatedResult } from '@shared/models/plugins/register-server-auth.model' |
15 | import { buildPluginHelpers } from './plugin-helpers' | ||
16 | import { logger } from '@server/helpers/logger' | ||
17 | import { RegisterServerHookOptions } from '@shared/models/plugins/register-server-hook.model' | 14 | import { RegisterServerHookOptions } from '@shared/models/plugins/register-server-hook.model' |
18 | import { serverHookObject } from '@shared/models/plugins/server-hook.model' | ||
19 | import { RegisterServerSettingOptions } from '@shared/models/plugins/register-server-setting.model' | 15 | import { RegisterServerSettingOptions } from '@shared/models/plugins/register-server-setting.model' |
16 | import { serverHookObject } from '@shared/models/plugins/server-hook.model' | ||
20 | import * as express from 'express' | 17 | import * as express from 'express' |
21 | import { PluginVideoPrivacyManager } from '@shared/models/plugins/plugin-video-privacy-manager.model' | 18 | import { buildPluginHelpers } from './plugin-helpers' |
22 | import { PluginPlaylistPrivacyManager } from '@shared/models/plugins/plugin-playlist-privacy-manager.model' | ||
23 | import { | ||
24 | RegisterServerAuthExternalOptions, | ||
25 | RegisterServerAuthExternalResult, | ||
26 | RegisterServerAuthPassOptions | ||
27 | } from '@shared/models/plugins/register-server-auth.model' | ||
28 | import { onExternalAuthPlugin } from '@server/lib/auth' | ||
29 | 19 | ||
30 | type AlterableVideoConstant = 'language' | 'licence' | 'category' | 'privacy' | 'playlistPrivacy' | 20 | type AlterableVideoConstant = 'language' | 'licence' | 'category' | 'privacy' | 'playlistPrivacy' |
31 | type VideoConstant = { [key in number | string]: string } | 21 | type 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 | } |