Permalink
Browse files

add: setup options for registration scope and login mode

  • Loading branch information...
p3k committed Apr 21, 2018
1 parent 7520783 commit f617e44d830c179b372333631e24b9bd756f145b
@@ -45,6 +45,25 @@
</div>
</div>
</fieldset>
<fieldset class='uk-margin-top'>
<legend><% gettext 'Registration & Login' %></legend>
<div class='uk-form-row'>
<label class='uk-form-label' for='registrationScope'>
<% gettext 'Required Account Status' %>
</label>
<div class='uk-form-controls'>
<% root.select registrationScope %>
</div>
</div>
<div class='uk-form-row'>
<label class='uk-form-label' for='loginMode'>
<% gettext 'Login Mode' %>
</label>
<div class='uk-form-controls'>
<% root.select loginMode %>
</div>
</div>
</fieldset>
<fieldset class='uk-margin-top'>
<legend><% gettext 'Site Creation' %></legend>
<div class='uk-form-row'>
@@ -102,6 +102,20 @@ Admin.getPhaseOutModes = defineConstants(Admin, markgettext('Disabled'), markget
*/
Admin.getCreationScopes = defineConstants(Admin, markgettext('Privileged'), markgettext('Trusted'), markgettext('Regular'));
/**
* @function
* @returns {String[]}
* @see defineConstants
*/
Admin.getRegistrationScopes = defineConstants(Admin, markgettext('Privileged'), markgettext('None'));
/**
* @function
* @returns {String[]}
* @see defineConstants
*/
Admin.getLoginModes = defineConstants(Admin, markgettext('Disabled'), markgettext('Enabled'));
/**
* Convenience method for easily queueing jobs.
* @param {HopObject} target
@@ -589,13 +603,15 @@ Admin.prototype.update = function(data) {
root.map({
creationScope: data.creationScope,
creationDelay: data.creationDelay,
replyTo: data.replyTo,
loginMode: data.loginMode,
notificationScope: data.notificationScope,
phaseOutGracePeriod: data.phaseOutGracePeriod,
phaseOutMode: data.phaseOutMode,
phaseOutNotificationPeriod: data.phaseOutNotificationPeriod,
probationPeriod: data.probationPeriod,
quota: data.quota
quota: data.quota,
registrationScope: data.registrationScope,
replyTo: data.replyTo
});
return;
}
@@ -128,7 +128,7 @@ HopObject.prototype.onRequest = function() {
res.skinpath = res.handlers.layout.getSkinPath();
if (!this.getPermission(req.action)) {
if (!session.user) {
if (!session.user && root.loginMode === Admin.ENABLED) {
User.setLocation(root.href() + req.path);
res.message = gettext('Please login first.');
res.redirect(res.handlers.site.members.href('login'));
@@ -40,12 +40,16 @@ markgettext('members');
*/
Members.prototype.getPermission = function(action) {
switch (action) {
case 'login':
case 'logout':
case 'register':
case 'reset':
case 'salt.txt':
return true;
case 'login':
return root.loginMode === Admin.ENABLED;
case 'register':
return root.registrationScope !== User.PRIVILEGED || User.require(User.PRIVILEGED);
}
var sitePermission = this._parent.getPermission('main');
@@ -12,7 +12,7 @@
<% #login %>
<div class='uk-margin-left uk-text-small uk-text-muted'>
<% gettext "You are not logged in" %>
<% if <% site.members.link login %> is null then '' else <% gettext "You are not logged in" %> %>
</div>
<ul class='uk-nav uk-nav-side'>
<li><% site.members.link login <% gettext Login context=verb prefix="<i class='uk-icon-sign-in'></i> " %> %></li>
@@ -357,10 +357,14 @@ Root.prototype.getFormOptions = function(name) {
switch (name) {
case 'creationScope':
return Admin.getCreationScopes();
case 'loginMode':
return Admin.getLoginModes();
case 'notificationScope':
return Admin.getNotificationScopes();
case 'phaseOutMode':
return Admin.getPhaseOutModes();
case 'registrationScope':
return Admin.getRegistrationScopes();
}
return Site.prototype.getFormOptions.apply(root, arguments);
}
@@ -0,0 +1,22 @@
// The Antville Project
// http://code.google.com/p/antville
//
// Copyright 2001–2018 by the Workers of Antville.
//
// Licensed under the Apache License, Version 2.0 (the ``License'');
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an ``AS IS'' BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Apply with enabled updater repository using `ant patch -Dpatch.id=20180421`
if (!root.loginMode) root.loginMode = Admin.ENABLED;
if (!root.registrationScope) root.registrationScope = Admin.NONE;

0 comments on commit f617e44

Please sign in to comment.