diff --git a/peertube-plugin-auth-ldap/main.js b/peertube-plugin-auth-ldap/main.js index 0b6fc7c..1360546 100644 --- a/peertube-plugin-auth-ldap/main.js +++ b/peertube-plugin-auth-ldap/main.js @@ -1,11 +1,23 @@ const LdapAuth = require('ldapauth-fork') -async function register ({ - registerIdAndPassAuth, - registerSetting, - settingsManager, +const store = { + weight: 100 +} + +async function register ({ + registerIdAndPassAuth, + registerSetting, + settingsManager, peertubeHelpers }) { + registerSetting({ + name: 'weight', + label: 'Auth weight', + type: 'input', + private: true, + default: 100 + }) + registerSetting({ name: 'url', label: 'URL', @@ -68,9 +80,15 @@ async function register ({ registerIdAndPassAuth({ authName: 'ldap', - getWeight: () => 100, + getWeight: () => store.weight, login: options => login(peertubeHelpers, settingsManager, options) }) + + store.weight = await settingsManager.getSetting('weight') + + settingsManager.onSettingsChange(settings => { + if (settigns && typeof settings.weight === 'number') store.weight = weight + }) } async function unregister () { @@ -154,4 +172,4 @@ async function login (peertubeHelpers, settingsManager, options) { }) }) }) -} \ No newline at end of file +} diff --git a/peertube-plugin-hello-world/main.js b/peertube-plugin-hello-world/main.js index 8eefa96..e27c242 100644 --- a/peertube-plugin-hello-world/main.js +++ b/peertube-plugin-hello-world/main.js @@ -89,7 +89,7 @@ async function register ({ { const result = registerExternalAuth({ authName: 'fake-auth', - authDisplayName: 'fake auth', + authDisplayName: () => 'fake auth', onAuthRequest: (req, res) => { result.userAuthenticated({ req,