hide references to registration if registration is disabled

pull/1/head
ansuz 4 years ago
parent 18c73ad282
commit 8546e7b317

@ -146,7 +146,7 @@ define([
]), ]),
]); ]);
var availableFeatures = var availableFeatures =
(Config.allowSubscriptions && accounts.upgradeURL) ? (Config.allowSubscriptions && accounts.upgradeURL && !Config.restrictRegistration) ?
[anonymousFeatures, registeredFeatures, premiumFeatures] : [anonymousFeatures, registeredFeatures, premiumFeatures] :
[anonymousFeatures, registeredFeatures]; [anonymousFeatures, registeredFeatures];

@ -2,8 +2,9 @@ define([
'/common/hyperscript.js', '/common/hyperscript.js',
'/common/common-interface.js', '/common/common-interface.js',
'/customize/messages.js', '/customize/messages.js',
'/customize/pages.js' '/customize/pages.js',
], function (h, UI, Msg, Pages) { '/api/config',
], function (h, UI, Msg, Pages, Config) {
return function () { return function () {
return [h('div#cp-main', [ return [h('div#cp-main', [
Pages.infopageTopbar(), Pages.infopageTopbar(),
@ -32,7 +33,10 @@ define([
]), ]),
h('div.extra', [ h('div.extra', [
h('button.login', Msg.login_login), h('button.login', Msg.login_login),
h('button#register.cp-secondary', Msg.login_register) (Config.restrictRegistration?
undefined:
h('button#register.cp-secondary', Msg.login_register)
)
]) ])
]), ]),
h('div.col-md-3') h('div.col-md-3')

@ -16,54 +16,67 @@ define([
tabindex: '-1', tabindex: '-1',
}); });
return [h('div#cp-main', [
Pages.infopageTopbar(), var frame = function (content) {
h('div.container.cp-container', [ return [
h('div.row.cp-page-title', h('h1', Msg.register_header)), h('div#cp-main', [
h('div.row.cp-register-det', [ Pages.infopageTopbar(),
h('div#data.hidden.col-md-6', [ h('div.container.cp-container', [
h('h2', Msg.register_notes_title), h('div.row.cp-page-title', h('h1', Msg.register_header)),
Pages.setHTML(h('div.cp-register-notes'), Msg.register_notes) h('div.row.cp-register-det', content),
]),
]), ]),
h('div.cp-reg-form.col-md-6', [ Pages.infopageFooter(),
h('img.img-fluid', { ];
src: '/customize/images/swallow-the-key.png?' + urlArgs };
if (Config.restrictRegistration) { // XXX restricted-registration
Msg.register_closed = "This instance does not allow registration at the moment.";
return frame([
h('h4', Msg.register_closed)
]);
}
return frame([
h('div#data.hidden.col-md-6', [
h('h2', Msg.register_notes_title),
Pages.setHTML(h('div.cp-register-notes'), Msg.register_notes)
]),
h('div.cp-reg-form.col-md-6', [
h('img.img-fluid', {
src: '/customize/images/swallow-the-key.png?' + urlArgs
}),
h('div#userForm.form-group.hidden', [
h('a', {
href: '/features.html'
}, Msg.register_whyRegister),
h('input.form-control#username', {
type: 'text',
autocomplete: 'off',
autocorrect: 'off',
autocapitalize: 'off',
spellcheck: false,
placeholder: Msg.login_username,
autofocus: true,
}), }),
h('div#userForm.form-group.hidden', [ h('input.form-control#password', {
h('a', { type: 'password',
href: '/features.html' placeholder: Msg.login_password,
}, Msg.register_whyRegister), }),
h('input.form-control#username', { h('input.form-control#password-confirm', {
type: 'text', type: 'password',
autocomplete: 'off', placeholder: Msg.login_confirm,
autocorrect: 'off', }),
autocapitalize: 'off', h('div.checkbox-container', [
spellcheck: false, UI.createCheckbox('import-recent', Msg.register_importRecent, true)
placeholder: Msg.login_username, ]),
autofocus: true, h('div.checkbox-container', [
}), tos,
h('input.form-control#password', { ]),
type: 'password', h('button#register', Msg.login_register)
placeholder: Msg.login_password, ])
}),
h('input.form-control#password-confirm', {
type: 'password',
placeholder: Msg.login_confirm,
}),
h('div.checkbox-container', [
UI.createCheckbox('import-recent', Msg.register_importRecent, true)
]),
h('div.checkbox-container', [
tos,
]),
h('button#register', Msg.login_register)
])
]),
]),
]), ]),
]);
Pages.infopageFooter(),
])];
}; };
}); });

@ -1833,14 +1833,16 @@ define([
Common.setLoginRedirect('login'); Common.setLoginRedirect('login');
}, },
}); });
options.push({ if (!Config.restrictRegistration) {
tag: 'a', options.push({
attributes: {'class': 'cp-toolbar-menu-register fa fa-user-plus'}, tag: 'a',
content: h('span', Messages.login_register), attributes: {'class': 'cp-toolbar-menu-register fa fa-user-plus'},
action: function () { content: h('span', Messages.login_register),
Common.setLoginRedirect('register'); action: function () {
}, Common.setLoginRedirect('register');
}); },
});
}
} }
var $icon = $('<span>', {'class': 'fa fa-user-secret'}); var $icon = $('<span>', {'class': 'fa fa-user-secret'});
//var $userbig = $('<span>', {'class': 'big'}).append($displayedName.clone()); //var $userbig = $('<span>', {'class': 'big'}).append($displayedName.clone());

@ -11,18 +11,12 @@ define([
'/common/common-feedback.js', '/common/common-feedback.js',
'/common/outer/local-store.js', '/common/outer/local-store.js',
'/common/hyperscript.js', '/common/hyperscript.js',
'/api/config',
'css!/bower_components/components-font-awesome/css/font-awesome.min.css', 'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
], function ($, Login, Cryptpad, Test, Cred, UI, Util, Realtime, Constants, Feedback, LocalStore, h, ApiConfig) { ], function ($, Login, Cryptpad, Test, Cred, UI, Util, Realtime, Constants, Feedback, LocalStore, h) {
var Messages = Cryptpad.Messages; var Messages = Cryptpad.Messages;
Messages.register_registrationIsClosed = "REGISTRATION IS CLOSED ON THIS INSTANCE."; // XXX Messages.register_registrationIsClosed = "REGISTRATION IS CLOSED ON THIS INSTANCE."; // XXX
$(function () { $(function () {
if (ApiConfig.restrictRegistration) {
return void UI.alert(Messages.register_registrationIsClosed); // XXX restricted-registration better UI ?
// remove the form and display text instead of an alert that people will probably dismiss?
}
if (LocalStore.isLoggedIn()) { if (LocalStore.isLoggedIn()) {
// already logged in, redirect to drive // already logged in, redirect to drive
document.location.href = '/drive/'; document.location.href = '/drive/';

Loading…
Cancel
Save