diff --git a/app/assets/javascripts/app.js b/app/assets/javascripts/app.js index 396a62b28..0c1f53813 100644 --- a/app/assets/javascripts/app.js +++ b/app/assets/javascripts/app.js @@ -17,7 +17,7 @@ Application.Directives = angular.module('application.directives', []); angular.module('application', ['ngCookies', 'ngResource', 'ngSanitize', 'ui.router', 'ui.bootstrap', 'ngUpload', 'duScroll', 'application.filters', 'application.services', 'application.directives', 'frapontillo.bootstrap-switch', 'application.constants', 'application.controllers', 'application.router', - 'ui.select', 'ui.calendar', 'angularMoment', 'Devise', 'DeviseModal', 'angular-growl', 'xeditable', + 'ui.select', 'ui.calendar', 'angularMoment', 'Devise', 'angular-growl', 'xeditable', 'checklist-model', 'unsavedChanges', 'angular-loading-bar', 'ngTouch', 'angular-google-analytics', 'angularUtils.directives.dirDisqus', 'summernote', 'elasticsearch', 'angular-medium-editor', 'naif.base64', 'minicolors', 'pascalprecht.translate', 'ngFitText', 'ngAside', 'ngCapsLock', 'vcRecaptcha', 'ui.codemirror', @@ -81,8 +81,6 @@ angular.module('application', ['ngCookies', 'ngResource', 'ngSanitize', 'ui.rout $state.prevParams = fromParams; }); - // Global config: if true, user must confirm his email to sign in - $rootScope.userConfirmationNeededToSignIn = Fablab.userConfirmationNeededToSignIn; // Global config: if true, wallet will be disabled $rootScope.fablabWithoutWallet = Fablab.fablabWithoutWallet; diff --git a/app/assets/javascripts/controllers/application.js.erb b/app/assets/javascripts/controllers/application.js.erb index beabf0cea..206e74a09 100644 --- a/app/assets/javascripts/controllers/application.js.erb +++ b/app/assets/javascripts/controllers/application.js.erb @@ -92,7 +92,7 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco templateUrl: '<%= asset_path "shared/signupModal.html" %>', size: 'md', resolve: { - settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['phone_required', 'recaptcha_site_key']" }).$promise; }] + settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['phone_required', 'recaptcha_site_key', 'confirmation_required']" }).$promise; }] }, controller: ['$scope', '$uibModalInstance', 'Group', 'CustomAsset', 'settingsPromise', 'growl', '_t', function ($scope, $uibModalInstance, Group, CustomAsset, settingsPromise, growl, _t) { // default parameters for the date picker in the account creation modal @@ -153,7 +153,7 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco return Auth.register($scope.user).then(function (user) { if (user.id) { // creation successful - $uibModalInstance.close(user); + $uibModalInstance.close({ user, settings: settingsPromise }); } else { // the user was not saved in database, something wrong occurred growl.error(_t('app.public.common.unexpected_error_occurred')); @@ -174,13 +174,13 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco }); }; }] - }).result['finally'](null).then(function (user) { + }).result['finally'](null).then(function (res) { // when the account was created successfully, set the session to the newly created account - if(Fablab.userConfirmationNeededToSignIn) { + if(res.settings.confirmation_required) { Auth._currentUser = null; growl.info(_t('app.public.common.you_will_receive_confirmation_instructions_by_email_detailed')); } else { - $scope.setCurrentUser(user); + $scope.setCurrentUser(res.user); } }); <% end %> @@ -409,8 +409,15 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco return $uibModal.open({ templateUrl: '<%= asset_path "shared/deviseModal.html" %>', size: 'sm', - controller: ['$scope', '$uibModalInstance', '_t', function ($scope, $uibModalInstance, _t) { + resolve: { + settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['confirmation_required']" }).$promise; }] + }, + controller: ['$scope', '$uibModalInstance', '_t', 'settingsPromise', function ($scope, $uibModalInstance, _t, settingsPromise) { const user = ($scope.user = {}); + + // email confirmation required before user sign-in? + $scope.confirmationRequired = settingsPromise.confirmation_required; + $scope.login = function () { Auth.login(user).then(function (user) { // Authentication succeeded ... @@ -441,7 +448,7 @@ Application.Controllers.controller('ApplicationController', ['$rootScope', '$sco return $uibModalInstance.dismiss('confirmationNew'); }; - return $scope.openResetPassword = function (e) { + $scope.openResetPassword = function (e) { e.preventDefault(); return $uibModalInstance.dismiss('resetPassword'); }; diff --git a/app/assets/javascripts/router.js.erb b/app/assets/javascripts/router.js.erb index 678c35ab5..23b3a7d20 100644 --- a/app/assets/javascripts/router.js.erb +++ b/app/assets/javascripts/router.js.erb @@ -1032,7 +1032,7 @@ angular.module('application.router', ['ui.router']) 'space_explications_alert', 'booking_window_start', 'booking_window_end', 'events_in_calendar', \ 'booking_move_enable', 'booking_move_delay', 'booking_cancel_enable', 'feature_tour_display', \ 'booking_cancel_delay', 'main_color', 'secondary_color', 'spaces_module', 'twitter_analytics', \ - 'fablab_name', 'name_genre', 'reminder_enable', 'plans_module', \ + 'fablab_name', 'name_genre', 'reminder_enable', 'plans_module', 'confirmation_required', \ 'reminder_delay', 'visibility_yearly', 'visibility_others', \ 'display_name_enable', 'machines_sort_by', 'fab_analytics', \ 'link_name', 'home_content', 'home_css', 'phone_required']` }).$promise; diff --git a/app/assets/templates/admin/settings/general.html b/app/assets/templates/admin/settings/general.html index 3a53a5075..8b25c22cd 100644 --- a/app/assets/templates/admin/settings/general.html +++ b/app/assets/templates/admin/settings/general.html @@ -422,6 +422,20 @@ +
+

{{ 'app.admin.settings.account_confirmation' }}

+

+ {{ 'app.admin.settings.confirmation_required_info' }} +

+
+ + +
+
diff --git a/app/assets/templates/shared/deviseModal.html.erb b/app/assets/templates/shared/deviseModal.html.erb index 1fd56c37e..cf5153e39 100644 --- a/app/assets/templates/shared/deviseModal.html.erb +++ b/app/assets/templates/shared/deviseModal.html.erb @@ -42,7 +42,7 @@ ng-minlength="8"/> {{ 'app.public.common.password_forgotten' | translate }} - +
{{ 'app.public.common.confirm_my_account' | translate }}