aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/plugins/plugin-manager.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-23 11:36:50 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-04 16:21:39 +0200
commite1c5503114deef954731904695cd40dccfcef555 (patch)
tree72cec4ee691a3362a7d024dc830d215a6b2c800a /server/lib/plugins/plugin-manager.ts
parent8dc8a34ee8428e7657414115d1c137592efa174d (diff)
downloadPeerTube-e1c5503114deef954731904695cd40dccfcef555.tar.gz
PeerTube-e1c5503114deef954731904695cd40dccfcef555.tar.zst
PeerTube-e1c5503114deef954731904695cd40dccfcef555.zip
Support logout and add id and pass tests
Diffstat (limited to 'server/lib/plugins/plugin-manager.ts')
-rw-r--r--server/lib/plugins/plugin-manager.ts20
1 files changed, 18 insertions, 2 deletions
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index f78b989f5..9d646b689 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -76,7 +76,7 @@ export class PluginManager implements ServerHook {
76 return this.registeredPlugins[npmName] 76 return this.registeredPlugins[npmName]
77 } 77 }
78 78
79 getRegisteredPlugin (name: string) { 79 getRegisteredPluginByShortName (name: string) {
80 const npmName = PluginModel.buildNpmName(name, PluginType.PLUGIN) 80 const npmName = PluginModel.buildNpmName(name, PluginType.PLUGIN)
81 const registered = this.getRegisteredPluginOrTheme(npmName) 81 const registered = this.getRegisteredPluginOrTheme(npmName)
82 82
@@ -85,7 +85,7 @@ export class PluginManager implements ServerHook {
85 return registered 85 return registered
86 } 86 }
87 87
88 getRegisteredTheme (name: string) { 88 getRegisteredThemeByShortName (name: string) {
89 const npmName = PluginModel.buildNpmName(name, PluginType.THEME) 89 const npmName = PluginModel.buildNpmName(name, PluginType.THEME)
90 const registered = this.getRegisteredPluginOrTheme(npmName) 90 const registered = this.getRegisteredPluginOrTheme(npmName)
91 91
@@ -132,6 +132,22 @@ export class PluginManager implements ServerHook {
132 return this.translations[locale] || {} 132 return this.translations[locale] || {}
133 } 133 }
134 134
135 onLogout (npmName: string, authName: string) {
136 const plugin = this.getRegisteredPluginOrTheme(npmName)
137 if (!plugin || plugin.type !== PluginType.PLUGIN) return
138
139 const auth = plugin.registerHelpersStore.getIdAndPassAuths()
140 .find(a => a.authName === authName)
141
142 if (auth.onLogout) {
143 try {
144 auth.onLogout()
145 } catch (err) {
146 logger.warn('Cannot run onLogout function from auth %s of plugin %s.', authName, npmName, { err })
147 }
148 }
149 }
150
135 // ###################### Hooks ###################### 151 // ###################### Hooks ######################
136 152
137 async runHook<T> (hookName: ServerHookName, result?: T, params?: any): Promise<T> { 153 async runHook<T> (hookName: ServerHookName, result?: T, params?: any): Promise<T> {