disable signup when closedRegistration

This commit is contained in:
Travis Eden 2018-09-19 15:14:20 -04:00
parent 815149a2cd
commit 845a0a3b01

View file

@ -2,6 +2,7 @@ const PassportLocalStrategy = require('passport-local').Strategy;
const { createChannel } = require('../../lbrynet'); const { createChannel } = require('../../lbrynet');
const logger = require('winston'); const logger = require('winston');
const db = require('../../models'); const db = require('../../models');
const { publishing: { closedRegistration } } = require('@config/siteConfig');
module.exports = new PassportLocalStrategy( module.exports = new PassportLocalStrategy(
{ {
@ -9,10 +10,13 @@ module.exports = new PassportLocalStrategy(
passwordField: 'password', passwordField: 'password',
}, },
(username, password, done) => { (username, password, done) => {
if (closedRegistration) {
return done('Registration is disabled');
}
logger.verbose(`new channel signup request. user: ${username} pass: ${password} .`); logger.verbose(`new channel signup request. user: ${username} pass: ${password} .`);
let userInfo = {}; let userInfo = {};
// server-side validaton of inputs (username, password) // server-side validaton of inputs (username, password)
// create the channel and retrieve the metadata // create the channel and retrieve the metadata
return createChannel(`@${username}`) return createChannel(`@${username}`)
.then(tx => { .then(tx => {