Code use user.active?
This commit is contained in:
parent
b193dd1465
commit
5643e671a0
5 changed files with 7 additions and 7 deletions
|
@ -250,7 +250,7 @@ class ApplicationController < ActionController::Base
|
||||||
payload: {
|
payload: {
|
||||||
DS_SIGN_IN_COUNT: current_user&.sign_in_count,
|
DS_SIGN_IN_COUNT: current_user&.sign_in_count,
|
||||||
DS_CREATED_AT: current_administrateur&.created_at,
|
DS_CREATED_AT: current_administrateur&.created_at,
|
||||||
DS_ACTIVE: current_administrateur&.active?,
|
DS_ACTIVE: current_user&.active?,
|
||||||
DS_ID: current_administrateur&.id,
|
DS_ID: current_administrateur&.id,
|
||||||
DS_GESTIONNAIRE_ID: current_instructeur&.id,
|
DS_GESTIONNAIRE_ID: current_instructeur&.id,
|
||||||
DS_ROLES: current_user_roles
|
DS_ROLES: current_user_roles
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Administrateur < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def registration_state
|
def registration_state
|
||||||
if active?
|
if user.active?
|
||||||
'Actif'
|
'Actif'
|
||||||
elsif user.reset_password_period_valid?
|
elsif user.reset_password_period_valid?
|
||||||
'En attente'
|
'En attente'
|
||||||
|
@ -56,7 +56,7 @@ class Administrateur < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def invitation_expired?
|
def invitation_expired?
|
||||||
!active? && !user.reset_password_period_valid?
|
!user.active? && !user.reset_password_period_valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.reset_password(reset_password_token, password)
|
def self.reset_password(reset_password_token, password)
|
||||||
|
|
|
@ -49,7 +49,7 @@ class User < ApplicationRecord
|
||||||
def invite_administrateur!(administration_id)
|
def invite_administrateur!(administration_id)
|
||||||
reset_password_token = nil
|
reset_password_token = nil
|
||||||
|
|
||||||
if !administrateur.active?
|
if !active?
|
||||||
reset_password_token = set_reset_password_token
|
reset_password_token = set_reset_password_token
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ class AdministrateurUsageStatisticsService
|
||||||
result = {
|
result = {
|
||||||
ds_sign_in_count: administrateur.user.sign_in_count,
|
ds_sign_in_count: administrateur.user.sign_in_count,
|
||||||
ds_created_at: administrateur.created_at,
|
ds_created_at: administrateur.created_at,
|
||||||
ds_active: administrateur.active?,
|
ds_active: administrateur.user.active?,
|
||||||
ds_id: administrateur.id,
|
ds_id: administrateur.id,
|
||||||
nb_services: nb_services_by_administrateur_id[administrateur.id],
|
nb_services: nb_services_by_administrateur_id[administrateur.id],
|
||||||
nb_instructeurs: nb_instructeurs_by_administrateur_id[administrateur.id],
|
nb_instructeurs: nb_instructeurs_by_administrateur_id[administrateur.id],
|
||||||
|
|
|
@ -12,7 +12,7 @@ feature 'As an administrateur', js: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'I can register' do
|
scenario 'I can register' do
|
||||||
expect(new_admin.reload.active?).to be(false)
|
expect(new_admin.reload.user.active?).to be(false)
|
||||||
|
|
||||||
confirmation_email = open_email(admin_email)
|
confirmation_email = open_email(admin_email)
|
||||||
token_params = confirmation_email.body.match(/token=[^"]+/)
|
token_params = confirmation_email.body.match(/token=[^"]+/)
|
||||||
|
@ -24,6 +24,6 @@ feature 'As an administrateur', js: true do
|
||||||
|
|
||||||
expect(page).to have_content 'Mot de passe enregistré'
|
expect(page).to have_content 'Mot de passe enregistré'
|
||||||
|
|
||||||
expect(new_admin.reload.active?).to be(true)
|
expect(new_admin.reload.user.active?).to be(true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue