1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 10:19:35 +02:00

Support logout and add id and pass tests

This commit is contained in:
Chocobozzz 2020-04-23 11:36:50 +02:00 committed by Chocobozzz
parent 8dc8a34ee8
commit e1c5503114
25 changed files with 273 additions and 101 deletions

View file

@ -76,7 +76,7 @@ export class PluginManager implements ServerHook {
return this.registeredPlugins[npmName]
}
getRegisteredPlugin (name: string) {
getRegisteredPluginByShortName (name: string) {
const npmName = PluginModel.buildNpmName(name, PluginType.PLUGIN)
const registered = this.getRegisteredPluginOrTheme(npmName)
@ -85,7 +85,7 @@ export class PluginManager implements ServerHook {
return registered
}
getRegisteredTheme (name: string) {
getRegisteredThemeByShortName (name: string) {
const npmName = PluginModel.buildNpmName(name, PluginType.THEME)
const registered = this.getRegisteredPluginOrTheme(npmName)
@ -132,6 +132,22 @@ export class PluginManager implements ServerHook {
return this.translations[locale] || {}
}
onLogout (npmName: string, authName: string) {
const plugin = this.getRegisteredPluginOrTheme(npmName)
if (!plugin || plugin.type !== PluginType.PLUGIN) return
const auth = plugin.registerHelpersStore.getIdAndPassAuths()
.find(a => a.authName === authName)
if (auth.onLogout) {
try {
auth.onLogout()
} catch (err) {
logger.warn('Cannot run onLogout function from auth %s of plugin %s.', authName, npmName, { err })
}
}
}
// ###################### Hooks ######################
async runHook<T> (hookName: ServerHookName, result?: T, params?: any): Promise<T> {