mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
closes #679
This commit is contained in:
@@ -77,6 +77,11 @@
|
|||||||
<form>
|
<form>
|
||||||
<h3>User Settings</h3>
|
<h3>User Settings</h3>
|
||||||
<div class="alert alert-warning">
|
<div class="alert alert-warning">
|
||||||
|
<div class="checkbox">
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" data-field="allowRegistration" checked> <strong>Allow registration</strong>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
<strong>Minimum Username Length</strong><br />
|
<strong>Minimum Username Length</strong><br />
|
||||||
<input type="text" class="form-control" value="2" data-field="minimumUsernameLength"><br />
|
<input type="text" class="form-control" value="2" data-field="minimumUsernameLength"><br />
|
||||||
<strong>Maximum Username Length</strong><br />
|
<strong>Maximum Username Length</strong><br />
|
||||||
|
|||||||
@@ -112,9 +112,11 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<ul id="logged-out-menu" class="nav navbar-nav navbar-right">
|
<ul id="logged-out-menu" class="nav navbar-nav navbar-right">
|
||||||
|
<!-- IF allowRegistration -->
|
||||||
<li class="visible-lg visible-md visible-sm">
|
<li class="visible-lg visible-md visible-sm">
|
||||||
<a href="/register">[[global:register]]</a>
|
<a href="/register">[[global:register]]</a>
|
||||||
</li>
|
</li>
|
||||||
|
<!-- ENDIF allowRegistration -->
|
||||||
<li class="visible-lg visible-md visible-sm">
|
<li class="visible-lg visible-md visible-sm">
|
||||||
<a href="/login">[[global:login]]</a>
|
<a href="/login">[[global:login]]</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ var path = require('path'),
|
|||||||
config.maximumSignatureLength = meta.config.maximumSignatureLength;
|
config.maximumSignatureLength = meta.config.maximumSignatureLength;
|
||||||
config.useOutgoingLinksPage = meta.config.useOutgoingLinksPage;
|
config.useOutgoingLinksPage = meta.config.useOutgoingLinksPage;
|
||||||
config.allowGuestPosting = meta.config.allowGuestPosting;
|
config.allowGuestPosting = meta.config.allowGuestPosting;
|
||||||
|
config.allowRegistration = meta.config.allowRegistration || '1';
|
||||||
config.emailSetup = !!meta.config['email:from'];
|
config.emailSetup = !!meta.config['email:from'];
|
||||||
|
|
||||||
res.json(200, config);
|
res.json(200, config);
|
||||||
|
|||||||
@@ -193,6 +193,10 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
app.post('/register', function(req, res) {
|
app.post('/register', function(req, res) {
|
||||||
|
if(parseInt(meta.config.allowRegistration, 10) === 0) {
|
||||||
|
return res.send(403);
|
||||||
|
}
|
||||||
|
|
||||||
user.create(req.body.username, req.body.password, req.body.email, function(err, uid) {
|
user.create(req.body.username, req.body.password, req.body.email, function(err, uid) {
|
||||||
if (err === null && uid) {
|
if (err === null && uid) {
|
||||||
req.login({
|
req.login({
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ var path = require('path'),
|
|||||||
link_tags: linkTags,
|
link_tags: linkTags,
|
||||||
clientScripts: clientScripts,
|
clientScripts: clientScripts,
|
||||||
navigation: custom_header.navigation,
|
navigation: custom_header.navigation,
|
||||||
'cache-buster': meta.config['cache-buster'] ? '?v=' + meta.config['cache-buster'] : ''
|
'cache-buster': meta.config['cache-buster'] ? '?v=' + meta.config['cache-buster'] : '',
|
||||||
|
allowRegistration: parseInt(meta.config.allowRegistration, 10) === 1
|
||||||
};
|
};
|
||||||
|
|
||||||
var uid = '0';
|
var uid = '0';
|
||||||
@@ -389,6 +390,8 @@ var path = require('path'),
|
|||||||
res.redirect('/user/' + userslug);
|
res.redirect('/user/' + userslug);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
} else if(route === 'register' && parseInt(meta.config.allowRegistration, 10) === 0) {
|
||||||
|
return res.redirect('/403');
|
||||||
} else if (loginRequired.indexOf(route) !== -1 && !req.user) {
|
} else if (loginRequired.indexOf(route) !== -1 && !req.user) {
|
||||||
return res.redirect('/403');
|
return res.redirect('/403');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user