2020-04-22 10:07:04 -04:00
|
|
|
async function register ({
|
|
|
|
registerIdAndPassAuth,
|
2020-04-30 04:03:09 -04:00
|
|
|
peertubeHelpers,
|
|
|
|
settingsManager,
|
|
|
|
unregisterIdAndPassAuth
|
2020-04-22 10:07:04 -04:00
|
|
|
}) {
|
|
|
|
registerIdAndPassAuth({
|
2020-04-23 05:36:50 -04:00
|
|
|
authName: 'spyro-auth',
|
2020-04-22 10:07:04 -04:00
|
|
|
|
|
|
|
onLogout: () => {
|
|
|
|
peertubeHelpers.logger.info('On logout for auth 1 - 1')
|
|
|
|
},
|
|
|
|
|
|
|
|
getWeight: () => 15,
|
|
|
|
|
|
|
|
login (body) {
|
|
|
|
if (body.id === 'spyro' && body.password === 'spyro password') {
|
|
|
|
return Promise.resolve({
|
|
|
|
username: 'spyro',
|
|
|
|
email: 'spyro@example.com',
|
2020-04-23 05:36:50 -04:00
|
|
|
role: 2,
|
2020-04-22 10:07:04 -04:00
|
|
|
displayName: 'Spyro the Dragon'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
registerIdAndPassAuth({
|
2020-04-23 05:36:50 -04:00
|
|
|
authName: 'crash-auth',
|
2020-04-22 10:07:04 -04:00
|
|
|
|
|
|
|
onLogout: () => {
|
|
|
|
peertubeHelpers.logger.info('On logout for auth 1 - 2')
|
|
|
|
},
|
|
|
|
|
|
|
|
getWeight: () => 50,
|
|
|
|
|
|
|
|
login (body) {
|
|
|
|
if (body.id === 'crash' && body.password === 'crash password') {
|
|
|
|
return Promise.resolve({
|
|
|
|
username: 'crash',
|
|
|
|
email: 'crash@example.com',
|
2020-04-23 05:36:50 -04:00
|
|
|
role: 1,
|
2020-04-22 10:07:04 -04:00
|
|
|
displayName: 'Crash Bandicoot'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
})
|
2020-04-30 04:03:09 -04:00
|
|
|
|
|
|
|
settingsManager.onSettingsChange(settings => {
|
|
|
|
if (settings.disableSpyro) {
|
|
|
|
unregisterIdAndPassAuth('spyro-auth')
|
|
|
|
}
|
|
|
|
})
|
2020-04-22 10:07:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
async function unregister () {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
register,
|
|
|
|
unregister
|
|
|
|
}
|
|
|
|
|
|
|
|
// ###########################################################################
|