Merge pull request #6644 from tchak/fix-renew-token

fix(profile): prevent crashing on renew token action
This commit is contained in:
Paul Chavard 2021-11-16 20:06:23 +03:00 committed by GitHub
commit deaf26341d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View file

@ -1,10 +1,9 @@
module Users
class ProfilController < UserController
before_action :ensure_update_email_is_authorized, only: :update_email
before_action :find_transfers, only: [:show, :renew_api_token]
def show
@waiting_merge_emails = waiting_merge_emails
@waiting_transfers = current_user.dossiers.joins(:transfer).group('dossier_transfers.email').count.to_a
end
def renew_api_token
@ -56,6 +55,11 @@ module Users
private
def find_transfers
@waiting_merge_emails = waiting_merge_emails
@waiting_transfers = current_user.dossiers.joins(:transfer).group('dossier_transfers.email').count.to_a
end
def waiting_merge_emails
users_requesting_merge.pluck(:email)
end

View file

@ -5,7 +5,7 @@
#profil-page.container
%h1 Profil
- if @waiting_merge_emails&.any?
- if @waiting_merge_emails.present?
.card
.card-title Demande de fusion de comptes
%p
@ -37,7 +37,7 @@
application_name: APPLICATION_NAME,
legit_admin_domains: LEGIT_ADMIN_DOMAINS.join(', '))
= form_for @current_user, url: update_email_path, method: :patch, html: { class: 'form' } do |f|
= form_for current_user, url: update_email_path, method: :patch, html: { class: 'form' } do |f|
= f.email_field :email, value: nil, placeholder: 'Nouvelle adresse email', required: true
= f.submit "Changer mon adresse", class: 'button primary'
@ -50,7 +50,7 @@
= email_field_tag :next_owner, nil, required: true
= submit_tag "Transférer tous mes dossiers", class: 'button primary', data: { confirm: t('.transfer_confirmation') }
- if @waiting_transfers.any?
- if @waiting_transfers.present?
.card.warning
.card-title= t('.waiting_transfers')
%ul