Remove credenticals synchronisation logic
This commit is contained in:
parent
58ecf18390
commit
dab1519b8c
8 changed files with 0 additions and 57 deletions
|
@ -47,7 +47,6 @@ class Administrateurs::ActivateController < ApplicationController
|
||||||
|
|
||||||
if resource&.valid_password?(password)
|
if resource&.valid_password?(password)
|
||||||
sign_in resource
|
sign_in resource
|
||||||
resource.force_sync_credentials
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,7 +42,6 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
|
||||||
if sign_in_after_confirmation?(resource)
|
if sign_in_after_confirmation?(resource)
|
||||||
resource.remember_me = true
|
resource.remember_me = true
|
||||||
sign_in(resource)
|
sign_in(resource)
|
||||||
resource.force_sync_credentials
|
|
||||||
after_sign_in_path_for(resource_name)
|
after_sign_in_path_for(resource_name)
|
||||||
else
|
else
|
||||||
super(resource_name, resource)
|
super(resource_name, resource)
|
||||||
|
|
|
@ -101,7 +101,6 @@ class Users::SessionsController < Devise::SessionsController
|
||||||
if resource.valid_password?(params[:user][:password])
|
if resource.valid_password?(params[:user][:password])
|
||||||
resource.remember_me = remember_me
|
resource.remember_me = remember_me
|
||||||
sign_in resource
|
sign_in resource
|
||||||
resource.force_sync_credentials
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resource
|
resource
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
class Administrateur < ApplicationRecord
|
class Administrateur < ApplicationRecord
|
||||||
include CredentialsSyncableConcern
|
|
||||||
include EmailSanitizableConcern
|
include EmailSanitizableConcern
|
||||||
include ActiveRecord::SecureToken
|
include ActiveRecord::SecureToken
|
||||||
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
module CredentialsSyncableConcern
|
|
||||||
extend ActiveSupport::Concern
|
|
||||||
|
|
||||||
included do
|
|
||||||
after_update :sync_credentials
|
|
||||||
end
|
|
||||||
|
|
||||||
def sync_credentials
|
|
||||||
if saved_change_to_email? || saved_change_to_encrypted_password?
|
|
||||||
return force_sync_credentials
|
|
||||||
end
|
|
||||||
true
|
|
||||||
end
|
|
||||||
|
|
||||||
def force_sync_credentials
|
|
||||||
SyncCredentialsService.new(self.class, email_before_last_save, email, encrypted_password).change_credentials!
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,5 +1,4 @@
|
||||||
class Instructeur < ApplicationRecord
|
class Instructeur < ApplicationRecord
|
||||||
include CredentialsSyncableConcern
|
|
||||||
include EmailSanitizableConcern
|
include EmailSanitizableConcern
|
||||||
|
|
||||||
has_and_belongs_to_many :administrateurs
|
has_and_belongs_to_many :administrateurs
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
class User < ApplicationRecord
|
class User < ApplicationRecord
|
||||||
include CredentialsSyncableConcern
|
|
||||||
include EmailSanitizableConcern
|
include EmailSanitizableConcern
|
||||||
|
|
||||||
enum loged_in_with_france_connect: {
|
enum loged_in_with_france_connect: {
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
class SyncCredentialsService
|
|
||||||
def initialize(klass, email_before_last_save, email, encrypted_password)
|
|
||||||
@klass = klass
|
|
||||||
@email_before_last_save = email_before_last_save
|
|
||||||
@email = email
|
|
||||||
@encrypted_password = encrypted_password
|
|
||||||
end
|
|
||||||
|
|
||||||
def change_credentials!
|
|
||||||
if @klass != User
|
|
||||||
user = User.find_by(email: @email_before_last_save)
|
|
||||||
if user && !user.update_columns(email: @email, encrypted_password: @encrypted_password)
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if @klass != Instructeur
|
|
||||||
instructeur = Instructeur.find_by(email: @email_before_last_save)
|
|
||||||
if instructeur && !instructeur.update_columns(email: @email, encrypted_password: @encrypted_password)
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if @klass != Administrateur
|
|
||||||
administrateur = Administrateur.find_by(email: @email_before_last_save)
|
|
||||||
if administrateur && !administrateur.update_columns(email: @email, encrypted_password: @encrypted_password)
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue