aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/plugins/plugin-manager.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-29 09:04:42 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-04 16:21:39 +0200
commit9107d791e2eef9a1b24b0499dac8b9dbba8a792f (patch)
treef09b20f06008b094f3266b39063bc9785dfebf5f /server/lib/plugins/plugin-manager.ts
parent4a8d113b9b57d97ff13ad1608798eabca99643e4 (diff)
downloadPeerTube-9107d791e2eef9a1b24b0499dac8b9dbba8a792f.tar.gz
PeerTube-9107d791e2eef9a1b24b0499dac8b9dbba8a792f.tar.zst
PeerTube-9107d791e2eef9a1b24b0499dac8b9dbba8a792f.zip
Add external login tests
Diffstat (limited to 'server/lib/plugins/plugin-manager.ts')
-rw-r--r--server/lib/plugins/plugin-manager.ts13
1 files changed, 8 insertions, 5 deletions
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index c64ca60aa..38336bcc6 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -21,7 +21,8 @@ import { ClientHtml } from '../client-html'
21import { PluginTranslation } from '../../../shared/models/plugins/plugin-translation.model' 21import { PluginTranslation } from '../../../shared/models/plugins/plugin-translation.model'
22import { RegisterHelpersStore } from './register-helpers-store' 22import { RegisterHelpersStore } from './register-helpers-store'
23import { RegisterServerHookOptions } from '@shared/models/plugins/register-server-hook.model' 23import { RegisterServerHookOptions } from '@shared/models/plugins/register-server-hook.model'
24import { MOAuthTokenUser } from '@server/typings/models' 24import { MOAuthTokenUser, MUser } from '@server/typings/models'
25import { RegisterServerAuthPassOptions, RegisterServerAuthExternalOptions } from '@shared/models/plugins/register-server-auth.model'
25 26
26export interface RegisteredPlugin { 27export interface RegisteredPlugin {
27 npmName: string 28 npmName: string
@@ -133,14 +134,14 @@ export class PluginManager implements ServerHook {
133 return this.translations[locale] || {} 134 return this.translations[locale] || {}
134 } 135 }
135 136
136 onLogout (npmName: string, authName: string) { 137 onLogout (npmName: string, authName: string, user: MUser) {
137 const auth = this.getAuth(npmName, authName) 138 const auth = this.getAuth(npmName, authName)
138 139
139 if (auth?.onLogout) { 140 if (auth?.onLogout) {
140 logger.info('Running onLogout function from auth %s of plugin %s', authName, npmName) 141 logger.info('Running onLogout function from auth %s of plugin %s', authName, npmName)
141 142
142 try { 143 try {
143 auth.onLogout() 144 auth.onLogout(user)
144 } catch (err) { 145 } catch (err) {
145 logger.warn('Cannot run onLogout function from auth %s of plugin %s.', authName, npmName, { err }) 146 logger.warn('Cannot run onLogout function from auth %s of plugin %s.', authName, npmName, { err })
146 } 147 }
@@ -478,8 +479,10 @@ export class PluginManager implements ServerHook {
478 const plugin = this.getRegisteredPluginOrTheme(npmName) 479 const plugin = this.getRegisteredPluginOrTheme(npmName)
479 if (!plugin || plugin.type !== PluginType.PLUGIN) return null 480 if (!plugin || plugin.type !== PluginType.PLUGIN) return null
480 481
481 return plugin.registerHelpersStore.getIdAndPassAuths() 482 let auths: (RegisterServerAuthPassOptions | RegisterServerAuthExternalOptions)[] = plugin.registerHelpersStore.getIdAndPassAuths()
482 .find(a => a.authName === authName) 483 auths = auths.concat(plugin.registerHelpersStore.getExternalAuths())
484
485 return auths.find(a => a.authName === authName)
483 } 486 }
484 487
485 // ###################### Private getters ###################### 488 // ###################### Private getters ######################