don't show a checkbox for the terms of service if they don't exist

pull/1/head
ansuz 3 years ago
parent c65f6b6c16
commit 14f6d65c7a

@ -10,13 +10,14 @@ define([
var urlArgs = Config.requireConf.urlArgs; var urlArgs = Config.requireConf.urlArgs;
var tos = $(UI.createCheckbox('accept-terms')).find('.cp-checkmark-label').append(Msg.register_acceptTerms).parent()[0]; var tos = $(UI.createCheckbox('accept-terms')).find('.cp-checkmark-label').append(Msg.register_acceptTerms).parent()[0];
var termsLink = Pages.customURLs.terms;
$(tos).find('a').attr({ $(tos).find('a').attr({
href: '/terms.html', href: termsLink, // '/terms.html',
target: '_blank', target: '_blank',
tabindex: '-1', tabindex: '-1',
}); });
var frame = function (content) { var frame = function (content) {
return [ return [
h('div#cp-main', [ h('div#cp-main', [
@ -38,6 +39,11 @@ define([
]); ]);
} }
var termsCheck;
if (termsLink) {
termsCheck = h('div.checkbox-container', tos);
}
return frame([ return frame([
h('div.row.cp-register-det', [ h('div.row.cp-register-det', [
h('div#data.hidden.col-md-6', [ h('div#data.hidden.col-md-6', [
@ -72,9 +78,7 @@ define([
h('div.checkbox-container', [ h('div.checkbox-container', [
UI.createCheckbox('import-recent', Msg.register_importRecent, true) UI.createCheckbox('import-recent', Msg.register_importRecent, true)
]), ]),
h('div.checkbox-container', [ termsCheck,
tos,
]),
h('button#register', Msg.login_register) h('button#register', Msg.login_register)
]) ])
]), ]),

@ -11,9 +11,10 @@ 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',
'/customize/pages.js',
'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) { ], function ($, Login, Cryptpad, /*Test,*/ Cred, UI, Util, Realtime, Constants, Feedback, LocalStore, h, Pages) {
if (window.top !== window) { return; } if (window.top !== window) { return; }
var Messages = Cryptpad.Messages; var Messages = Cryptpad.Messages;
$(function () { $(function () {
@ -58,7 +59,14 @@ define([
var confirmPassword = $confirm.val(); var confirmPassword = $confirm.val();
var shouldImport = $checkImport[0].checked; var shouldImport = $checkImport[0].checked;
var doesAccept = $checkAcceptTerms[0].checked; var doesAccept;
try {
// if this throws there's either a horrible bug (which someone will report)
// or the instance admins did not configure a terms page.
doesAccept = $checkAcceptTerms[0].checked;
} catch (err) {
console.error(err);
}
if (Cred.isEmail(uname) && !I_REALLY_WANT_TO_USE_MY_EMAIL_FOR_MY_USERNAME) { if (Cred.isEmail(uname) && !I_REALLY_WANT_TO_USE_MY_EMAIL_FOR_MY_USERNAME) {
var emailWarning = [ var emailWarning = [
@ -94,7 +102,7 @@ define([
return void UI.alert(Messages.register_passwordsDontMatch); return void UI.alert(Messages.register_passwordsDontMatch);
} }
if (!doesAccept) { // do they accept the terms of service? if (Pages.customURLs.terms && !doesAccept) { // do they accept the terms of service? (if they exist)
return void UI.alert(Messages.register_mustAcceptTerms); return void UI.alert(Messages.register_mustAcceptTerms);
} }

Loading…
Cancel
Save