diff --git a/customize.dist/pages/features.js b/customize.dist/pages/features.js index ff67c6912..ee82d5d67 100644 --- a/customize.dist/pages/features.js +++ b/customize.dist/pages/features.js @@ -146,7 +146,7 @@ define([ ]), ]); var availableFeatures = - (Config.allowSubscriptions && accounts.upgradeURL) ? + (Config.allowSubscriptions && accounts.upgradeURL && !Config.restrictRegistration) ? [anonymousFeatures, registeredFeatures, premiumFeatures] : [anonymousFeatures, registeredFeatures]; diff --git a/customize.dist/pages/login.js b/customize.dist/pages/login.js index 5322c663f..45d3a3707 100644 --- a/customize.dist/pages/login.js +++ b/customize.dist/pages/login.js @@ -2,8 +2,9 @@ define([ '/common/hyperscript.js', '/common/common-interface.js', '/customize/messages.js', - '/customize/pages.js' -], function (h, UI, Msg, Pages) { + '/customize/pages.js', + '/api/config', +], function (h, UI, Msg, Pages, Config) { return function () { return [h('div#cp-main', [ Pages.infopageTopbar(), @@ -32,7 +33,10 @@ define([ ]), h('div.extra', [ 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') diff --git a/customize.dist/pages/register.js b/customize.dist/pages/register.js index 1cdc6e356..7af93853b 100644 --- a/customize.dist/pages/register.js +++ b/customize.dist/pages/register.js @@ -16,54 +16,67 @@ define([ tabindex: '-1', }); - return [h('div#cp-main', [ - Pages.infopageTopbar(), - h('div.container.cp-container', [ - h('div.row.cp-page-title', h('h1', Msg.register_header)), - h('div.row.cp-register-det', [ - h('div#data.hidden.col-md-6', [ - h('h2', Msg.register_notes_title), - Pages.setHTML(h('div.cp-register-notes'), Msg.register_notes) + + var frame = function (content) { + return [ + h('div#cp-main', [ + Pages.infopageTopbar(), + h('div.container.cp-container', [ + h('div.row.cp-page-title', h('h1', Msg.register_header)), + h('div.row.cp-register-det', content), + ]), ]), - h('div.cp-reg-form.col-md-6', [ - h('img.img-fluid', { - src: '/customize/images/swallow-the-key.png?' + urlArgs + Pages.infopageFooter(), + ]; + }; + + 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('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('input.form-control#password', { - type: 'password', - 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) - ]) - ]), - ]), + h('input.form-control#password', { + type: 'password', + 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(), - ])]; + ]); }; }); diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index 471bd5011..0f070595b 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -1833,14 +1833,16 @@ define([ Common.setLoginRedirect('login'); }, }); - options.push({ - tag: 'a', - attributes: {'class': 'cp-toolbar-menu-register fa fa-user-plus'}, - content: h('span', Messages.login_register), - action: function () { - Common.setLoginRedirect('register'); - }, - }); + if (!Config.restrictRegistration) { + options.push({ + tag: 'a', + attributes: {'class': 'cp-toolbar-menu-register fa fa-user-plus'}, + content: h('span', Messages.login_register), + action: function () { + Common.setLoginRedirect('register'); + }, + }); + } } var $icon = $('', {'class': 'fa fa-user-secret'}); //var $userbig = $('', {'class': 'big'}).append($displayedName.clone()); diff --git a/www/register/main.js b/www/register/main.js index b86b07b48..2c66aebb4 100644 --- a/www/register/main.js +++ b/www/register/main.js @@ -11,18 +11,12 @@ define([ '/common/common-feedback.js', '/common/outer/local-store.js', '/common/hyperscript.js', - '/api/config', '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; Messages.register_registrationIsClosed = "REGISTRATION IS CLOSED ON THIS INSTANCE."; // XXX $(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()) { // already logged in, redirect to drive document.location.href = '/drive/';