From 193ee4ffe98a2fbc27f49a056566de7d924d411b Mon Sep 17 00:00:00 2001 From: Sylvain Date: Tue, 18 Jan 2022 12:00:23 +0100 Subject: [PATCH] (bug) case-sensitive emails - for sso code sending - for adminsys configuration --- CHANGELOG.md | 3 +++ app/controllers/api/auth_providers_controller.rb | 3 +-- app/models/user.rb | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 143d7b3a6..c43576ee5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog Fab-manager +- Fix a bug: when requesting to send the sso migration code, the email was case-sensitive. +- Fix a bug: the adminsys email was case-sensitive. + # v5.3.1 2022 January 17 - Definition of extended prices for spaces is now made in hours (previously in minutes) diff --git a/app/controllers/api/auth_providers_controller.rb b/app/controllers/api/auth_providers_controller.rb index 6a4b5bea0..071b6a927 100644 --- a/app/controllers/api/auth_providers_controller.rb +++ b/app/controllers/api/auth_providers_controller.rb @@ -52,10 +52,9 @@ class API::AuthProvidersController < API::ApiController @previous = AuthProvider.previous end - def send_code authorize AuthProvider - user = User.find_by(email: params[:email]) + user = User.find_by('lower(email) = ?', params[:email]&.downcase) if user&.auth_token if AuthProvider.active.providable_type != DatabaseProvider.name diff --git a/app/models/user.rb b/app/models/user.rb index 4c0c2f36a..40efffd78 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -121,7 +121,7 @@ class User < ApplicationRecord def self.adminsys return unless Rails.application.secrets.adminsys_email.present? - User.find_by(email: Rails.application.secrets.adminsys_email) + User.find_by('lower(email) = ?', Rails.application.secrets.adminsys_email&.downcase) end def training_machine?(machine)