Add weight support in LDAP plugin
This commit is contained in:
parent
fc9be54433
commit
9b66758c3d
@ -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 () {
|
||||||
|
@ -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,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user