From e0df404d7e7a7a7012c66ab19ccb60b749443b1b Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Fri, 7 Feb 2014 16:04:00 -0500 Subject: [PATCH] Add site setting tos_accept_required. If enabled, users must check a box saying that they've read and accept the terms of service. --- .../controllers/create_account_controller.js | 8 +++++++- .../templates/modal/create_account.js.handlebars | 6 ++++++ app/assets/stylesheets/desktop/login.scss | 7 +++++++ app/controllers/application_controller.rb | 6 ++++-- app/models/site_content.rb | 1 + config/locales/client.en.yml | 1 + config/locales/server.en.yml | 5 +++++ config/site_settings.yml | 12 +++++++++--- 8 files changed, 40 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/create_account_controller.js b/app/assets/javascripts/discourse/controllers/create_account_controller.js index e9c393545e3..46062c9ebc2 100644 --- a/app/assets/javascripts/discourse/controllers/create_account_controller.js +++ b/app/assets/javascripts/discourse/controllers/create_account_controller.js @@ -17,6 +17,7 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF rejectedEmails: Em.A([]), rejectedPasswords: Em.A([]), prefilledUsername: null, + tosAccepted: false, resetForm: function() { this.setProperties({ @@ -36,12 +37,13 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF submitDisabled: function() { if (this.get('formSubmitted')) return true; + if (this.get('tosAcceptRequired') && !this.get('tosAccepted')) return true; if (this.get('nameValidation.failed')) return true; if (this.get('emailValidation.failed')) return true; if (this.get('usernameValidation.failed')) return true; if (this.get('passwordValidation.failed')) return true; return false; - }.property('nameValidation.failed', 'emailValidation.failed', 'usernameValidation.failed', 'passwordValidation.failed', 'formSubmitted'), + }.property('nameValidation.failed', 'emailValidation.failed', 'usernameValidation.failed', 'passwordValidation.failed', 'formSubmitted', 'tosAccepted'), passwordRequired: function() { return (this.blank('authOptions.auth_provider') || this.blank('authOptions.email_valid') || !this.get('authOptions.email_valid')); @@ -322,6 +324,10 @@ Discourse.CreateAccountController = Discourse.Controller.extend(Discourse.ModalF }); }, + tosAcceptRequired: function() { + return Discourse.SiteSettings.tos_accept_required; + }.property(), + actions: { createAccount: function() { var self = this; diff --git a/app/assets/javascripts/discourse/templates/modal/create_account.js.handlebars b/app/assets/javascripts/discourse/templates/modal/create_account.js.handlebars index fa44cceaf8f..072ecae0819 100644 --- a/app/assets/javascripts/discourse/templates/modal/create_account.js.handlebars +++ b/app/assets/javascripts/discourse/templates/modal/create_account.js.handlebars @@ -67,6 +67,12 @@