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 }}
diff --git a/app/models/setting.rb b/app/models/setting.rb
index 0f6f4944c..44c7dee35 100644
--- a/app/models/setting.rb
+++ b/app/models/setting.rb
@@ -100,7 +100,8 @@ class Setting < ApplicationRecord
stripe_public_key
stripe_secret_key
stripe_currency
- invoice_prefix] }
+ invoice_prefix
+ confirmation_required] }
# WARNING: when adding a new key, you may also want to add it in app/policies/setting_policy.rb#public_whitelist
def value
diff --git a/app/models/user.rb b/app/models/user.rb
index 4d611d109..23372aa39 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -341,7 +341,7 @@ class User < ApplicationRecord
end
def confirmation_required?
- Rails.application.secrets.user_confirmation_needed_to_sign_in ? super : false
+ Setting.get('confirmation_required') ? super : false
end
private
diff --git a/app/policies/setting_policy.rb b/app/policies/setting_policy.rb
index 45125a2a7..b49408d8a 100644
--- a/app/policies/setting_policy.rb
+++ b/app/policies/setting_policy.rb
@@ -38,7 +38,7 @@ class SettingPolicy < ApplicationPolicy
fablab_name name_genre event_explications_alert space_explications_alert link_name home_content phone_required
tracking_id book_overlapping_slots slot_duration events_in_calendar spaces_module plans_module invoicing_module
recaptcha_site_key feature_tour_display disqus_shortname allowed_cad_extensions openlab_app_id openlab_default
- online_payment_module stripe_public_key]
+ online_payment_module stripe_public_key confirmation_required]
end
##
diff --git a/app/views/application/index.html.erb b/app/views/application/index.html.erb
index 9da368ee9..0e0aa949a 100644
--- a/app/views/application/index.html.erb
+++ b/app/views/application/index.html.erb
@@ -47,7 +47,6 @@
Fablab.weekStartingDay = <%= Date.parse(Rails.application.secrets.week_starting_day).strftime('%w') %>;
Fablab.d3DateFormat = "<%= Rails.application.secrets.d3_date_format %>";
Fablab.uibDateFormat = "<%= Rails.application.secrets.uib_date_format %>";
- Fablab.userConfirmationNeededToSignIn = ('<%= Rails.application.secrets.user_confirmation_needed_to_sign_in %>' === 'true');
// feature tour (used when feature_tour_display = session)
Fablab.sessionTours = [];
diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml
index 542a9e2f8..86bb62be4 100644
--- a/config/locales/app.admin.en.yml
+++ b/config/locales/app.admin.en.yml
@@ -1106,6 +1106,9 @@ en:
openlab_default: "default gallery view"
online_payment_module: "online payment module"
stripe_currency: "Stripe currency"
+ account_confirmation: "Account confirmation"
+ confirmation_required_info: "Optionally, you can force the users to confirm their email address before being able to access Fab-manager."
+ confirmation_is_required: "Confirmation required"
general:
general: "General"
title: "Title"
diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml
index 526be66cb..1dedc9aab 100644
--- a/config/locales/app.admin.fr.yml
+++ b/config/locales/app.admin.fr.yml
@@ -1106,6 +1106,9 @@ fr:
openlab_default: "l'affichage par défaut de la galerie"
online_payment_module: "module de paiement en ligne"
stripe_currency: "la devise Stripe"
+ account_confirmation: "Confirmation de compte"
+ confirmation_required_info: "De manière optionnelle, vous pouvez forcer les utilisateurs à confirmer leur adresse électronique avant de pouvoir accéder à Fab-manager."
+ confirmation_is_required: "Confirmation requise"
general:
general: "Général"
title: "Titre"
diff --git a/config/secrets.yml b/config/secrets.yml
index 8235eef53..4437131f9 100644
--- a/config/secrets.yml
+++ b/config/secrets.yml
@@ -13,7 +13,6 @@
development:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
fablab_without_wallet: <%= ENV["FABLAB_WITHOUT_WALLET"] %>
- user_confirmation_needed_to_sign_in: <%= ENV["USER_CONFIRMATION_NEEDED_TO_SIGN_IN"] %>
default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
time_zone: <%= ENV["TIME_ZONE"] %>
@@ -42,7 +41,6 @@ development:
test:
secret_key_base: 83daf5e7b80d990f037407bab78dff9904aaf3c195a50f84fa8695a22287e707dfbd9524b403b1dcf116ae1d8c06844c3d7ed942564e5b46be6ae3ead93a9d30
fablab_without_wallet: false
- user_confirmation_needed_to_sign_in: <%= ENV["USER_CONFIRMATION_NEEDED_TO_SIGN_IN"] %>
default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
time_zone: Paris
@@ -71,7 +69,6 @@ test:
staging:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
fablab_without_wallet: <%= ENV["FABLAB_WITHOUT_WALLET"] %>
- user_confirmation_needed_to_sign_in: <%= ENV["USER_CONFIRMATION_NEEDED_TO_SIGN_IN"] %>
default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
delivery_method: <%= ENV['DELIVERY_METHOD'] %>
@@ -111,7 +108,6 @@ staging:
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
fablab_without_wallet: <%= ENV["FABLAB_WITHOUT_WALLET"] %>
- user_confirmation_needed_to_sign_in: <%= ENV["USER_CONFIRMATION_NEEDED_TO_SIGN_IN"] %>
default_host: <%= ENV["DEFAULT_HOST"] %>
default_protocol: <%= ENV["DEFAULT_PROTOCOL"] %>
delivery_method: <%= ENV['DELIVERY_METHOD'] %>
diff --git a/db/seeds.rb b/db/seeds.rb
index cb65e1108..59dcc149b 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -884,6 +884,8 @@ Setting.set('stripe_currency', 'EUR') unless Setting.find_by(name: 'stripe_curre
Setting.set('invoice_prefix', 'FabManager_invoice') unless Setting.find_by(name: 'invoice_prefix').try(:value)
+Setting.set('confirmation_required', false) unless Setting.find_by(name: 'confirmation_required').try(:value)
+
if StatisticCustomAggregation.count.zero?
# available reservations hours for machines
machine_hours = StatisticType.find_by(key: 'hour', statistic_index_id: 2)
diff --git a/doc/environment.md b/doc/environment.md
index 180bfaabe..4e1843f0f 100644
--- a/doc/environment.md
+++ b/doc/environment.md
@@ -57,12 +57,6 @@ You can generate such a random key by running `rails secret`.
If set to 'true', the wallet will be disabled.
This is useful if you won't use wallet system.
-
-
- USER_CONFIRMATION_NEEDED_TO_SIGN_IN
-
-If set to 'true' the users will need to confirm their email address to be able to sign in.
-Set to 'false' if you don't want this behaviour.
DELIVERY_METHOD
diff --git a/env.example b/env.example
index 1575b2a82..16f58d5ff 100644
--- a/env.example
+++ b/env.example
@@ -11,8 +11,6 @@ SECRET_KEY_BASE=83daf5e7b80d990f037407bab78dff9904aaf3c195a50f84fa8695a22287e707
# FabLab optional modules=
FABLAB_WITHOUT_WALLET=false
-USER_CONFIRMATION_NEEDED_TO_SIGN_IN=false
-
# Configure carefully!
DEFAULT_HOST=localhost:5000
DEFAULT_PROTOCOL=http
diff --git a/lib/tasks/fablab/setup.rake b/lib/tasks/fablab/setup.rake
index 14da2647c..cebcbecae 100644
--- a/lib/tasks/fablab/setup.rake
+++ b/lib/tasks/fablab/setup.rake
@@ -130,7 +130,8 @@ namespace :fablab do
%w[_ STRIPE_PUBLISHABLE_KEY stripe_public_key],
%w[_ STRIPE_API_KEY stripe_secret_key],
%w[_ STRIPE_CURRENCY stripe_currency],
- %w[_ INVOICE_PREFIX invoice_prefix FabManager_invoice]
+ %w[_ INVOICE_PREFIX invoice_prefix FabManager_invoice],
+ %w[_ USER_CONFIRMATION_NEEDED_TO_SIGN_IN confirmation_required false]
]
mapping.each do |m|
diff --git a/setup/setup.sh b/setup/setup.sh
index 18af901e1..2163d11de 100755
--- a/setup/setup.sh
+++ b/setup/setup.sh
@@ -235,7 +235,7 @@ configure_env_file()
local doc variables secret
doc=$(\curl -sSL https://raw.githubusercontent.com/sleede/fab-manager/master/doc/environment.md)
variables=(FABLAB_WITHOUT_WALLET \
- USER_CONFIRMATION_NEEDED_TO_SIGN_IN DEFAULT_HOST DEFAULT_PROTOCOL DELIVERY_METHOD SMTP_ADDRESS SMTP_PORT SMTP_USER_NAME SMTP_PASSWORD SMTP_AUTHENTICATION \
+ DEFAULT_HOST DEFAULT_PROTOCOL DELIVERY_METHOD SMTP_ADDRESS SMTP_PORT SMTP_USER_NAME SMTP_PASSWORD SMTP_AUTHENTICATION \
SMTP_ENABLE_STARTTLS_AUTO SMTP_OPENSSL_VERIFY_MODE SMTP_TLS \
LOG_LEVEL MAX_IMAGE_SIZE MAX_CAO_SIZE MAX_IMPORT_SIZE DISK_SPACE_MB_ALERT \
SUPERADMIN_EMAIL APP_LOCALE RAILS_LOCALE MOMENT_LOCALE SUMMERNOTE_LOCALE ANGULAR_LOCALE FULLCALENDAR_LOCALE ELASTICSEARCH_LANGUAGE_ANALYZER TIME_ZONE \
diff --git a/test/fixtures/history_values.yml b/test/fixtures/history_values.yml
index 8bcaa850c..b6f2bae4a 100644
--- a/test/fixtures/history_values.yml
+++ b/test/fixtures/history_values.yml
@@ -669,3 +669,11 @@ history_value_70:
name: FabManager_invoice
created_at: 2020-06-15 10:04:06.216541000 Z
updated_at: 2020-06-15 10:04:06.216541000 Z
+
+history_value_71:
+ id: 71
+ setting_id: 71
+ value: 1
+ name: false
+ created_at: 2020-06-15 10:04:06.216541000 Z
+ updated_at: 2020-06-15 10:04:06.216541000 Z
diff --git a/test/fixtures/settings.yml b/test/fixtures/settings.yml
index 7dd77a6ce..0042c495c 100644
--- a/test/fixtures/settings.yml
+++ b/test/fixtures/settings.yml
@@ -412,3 +412,10 @@ setting_70:
name: invoice_prefix
created_at: 2020-06-15 10:04:06.216541000 Z
updated_at: 2020-06-15 10:04:06.216541000 Z
+
+setting_71:
+ id: 71
+ name: confirmation_required
+ created_at: 2020-06-15 10:04:06.216541000 Z
+ updated_at: 2020-06-15 10:04:06.216541000 Z
+
diff --git a/vendor/assets/javascripts/devise-modal.js b/vendor/assets/javascripts/devise-modal.js
index 5fd9bf74f..7b7eade2f 100644
--- a/vendor/assets/javascripts/devise-modal.js
+++ b/vendor/assets/javascripts/devise-modal.js
@@ -1,4 +1,5 @@
'use strict';
+// TODO remove unused?
(function (angular) {
var deviseModal = angular.module('DeviseModal', [
'Devise',