Add weight support in LDAP plugin

This commit is contained in:
Chocobozzz 2020-04-30 10:14:51 +02:00
parent fc9be54433
commit 9b66758c3d
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 25 additions and 7 deletions

View File

@ -1,11 +1,23 @@
const LdapAuth = require('ldapauth-fork') const LdapAuth = require('ldapauth-fork')
const store = {
weight: 100
}
async function register ({ async function register ({
registerIdAndPassAuth, registerIdAndPassAuth,
registerSetting, registerSetting,
settingsManager, settingsManager,
peertubeHelpers peertubeHelpers
}) { }) {
registerSetting({
name: 'weight',
label: 'Auth weight',
type: 'input',
private: true,
default: 100
})
registerSetting({ registerSetting({
name: 'url', name: 'url',
label: 'URL', label: 'URL',
@ -68,9 +80,15 @@ async function register ({
registerIdAndPassAuth({ registerIdAndPassAuth({
authName: 'ldap', authName: 'ldap',
getWeight: () => 100, getWeight: () => store.weight,
login: options => login(peertubeHelpers, settingsManager, options) 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 () { async function unregister () {

View File

@ -89,7 +89,7 @@ async function register ({
{ {
const result = registerExternalAuth({ const result = registerExternalAuth({
authName: 'fake-auth', authName: 'fake-auth',
authDisplayName: 'fake auth', authDisplayName: () => 'fake auth',
onAuthRequest: (req, res) => { onAuthRequest: (req, res) => {
result.userAuthenticated({ result.userAuthenticated({
req, req,