aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/plugins/register-helpers-store.ts24
1 files changed, 20 insertions, 4 deletions
diff --git a/server/lib/plugins/register-helpers-store.ts b/server/lib/plugins/register-helpers-store.ts
index 6317ac2cf..a3ec7ef6a 100644
--- a/server/lib/plugins/register-helpers-store.ts
+++ b/server/lib/plugins/register-helpers-store.ts
@@ -49,8 +49,8 @@ export class RegisterHelpersStore {
49 49
50 private readonly settings: RegisterServerSettingOptions[] = [] 50 private readonly settings: RegisterServerSettingOptions[] = []
51 51
52 private readonly idAndPassAuths: RegisterServerAuthPassOptions[] = [] 52 private idAndPassAuths: RegisterServerAuthPassOptions[] = []
53 private readonly externalAuths: RegisterServerAuthExternalOptions[] = [] 53 private externalAuths: RegisterServerAuthExternalOptions[] = []
54 54
55 private readonly onSettingsChangeCallbacks: ((settings: any) => void)[] = [] 55 private readonly onSettingsChangeCallbacks: ((settings: any) => void)[] = []
56 56
@@ -83,6 +83,8 @@ export class RegisterHelpersStore {
83 83
84 const registerIdAndPassAuth = this.buildRegisterIdAndPassAuth() 84 const registerIdAndPassAuth = this.buildRegisterIdAndPassAuth()
85 const registerExternalAuth = this.buildRegisterExternalAuth() 85 const registerExternalAuth = this.buildRegisterExternalAuth()
86 const unregisterIdAndPassAuth = this.buildUnregisterIdAndPassAuth()
87 const unregisterExternalAuth = this.buildUnregisterExternalAuth()
86 88
87 const peertubeHelpers = buildPluginHelpers(this.npmName) 89 const peertubeHelpers = buildPluginHelpers(this.npmName)
88 90
@@ -104,6 +106,8 @@ export class RegisterHelpersStore {
104 106
105 registerIdAndPassAuth, 107 registerIdAndPassAuth,
106 registerExternalAuth, 108 registerExternalAuth,
109 unregisterIdAndPassAuth,
110 unregisterExternalAuth,
107 111
108 peertubeHelpers 112 peertubeHelpers
109 } 113 }
@@ -179,7 +183,7 @@ export class RegisterHelpersStore {
179 private buildRegisterIdAndPassAuth () { 183 private buildRegisterIdAndPassAuth () {
180 return (options: RegisterServerAuthPassOptions) => { 184 return (options: RegisterServerAuthPassOptions) => {
181 if (!options.authName || typeof options.getWeight !== 'function' || typeof options.login !== 'function') { 185 if (!options.authName || typeof options.getWeight !== 'function' || typeof options.login !== 'function') {
182 logger.error('Cannot register auth plugin %s: authName of getWeight or login are not valid.', this.npmName) 186 logger.error('Cannot register auth plugin %s: authName, getWeight or login are not valid.', this.npmName, { options })
183 return 187 return
184 } 188 }
185 189
@@ -192,7 +196,7 @@ export class RegisterHelpersStore {
192 196
193 return (options: RegisterServerAuthExternalOptions) => { 197 return (options: RegisterServerAuthExternalOptions) => {
194 if (!options.authName || typeof options.authDisplayName !== 'function' || typeof options.onAuthRequest !== 'function') { 198 if (!options.authName || typeof options.authDisplayName !== 'function' || typeof options.onAuthRequest !== 'function') {
195 logger.error('Cannot register auth plugin %s: authName of getWeight or login are not valid.', this.npmName) 199 logger.error('Cannot register auth plugin %s: authName, authDisplayName or onAuthRequest are not valid.', this.npmName, { options })
196 return 200 return
197 } 201 }
198 202
@@ -212,6 +216,18 @@ export class RegisterHelpersStore {
212 } 216 }
213 } 217 }
214 218
219 private buildUnregisterExternalAuth () {
220 return (authName: string) => {
221 this.externalAuths = this.externalAuths.filter(a => a.authName !== authName)
222 }
223 }
224
225 private buildUnregisterIdAndPassAuth () {
226 return (authName: string) => {
227 this.idAndPassAuths = this.idAndPassAuths.filter(a => a.authName !== authName)
228 }
229 }
230
215 private buildSettingsManager (): PluginSettingsManager { 231 private buildSettingsManager (): PluginSettingsManager {
216 return { 232 return {
217 getSetting: (name: string) => PluginModel.getSetting(this.plugin.name, this.plugin.type, name), 233 getSetting: (name: string) => PluginModel.getSetting(this.plugin.name, this.plugin.type, name),