merge with another preexisting account
This commit is contained in:
parent
ce40e1127d
commit
933d7b8c8d
7 changed files with 46 additions and 2 deletions
|
@ -73,7 +73,8 @@ class FranceConnect::ParticulierController < ApplicationController
|
|||
flash.notice = "Les comptes FranceConnect et #{APPLICATION_NAME} sont à présent fusionnés"
|
||||
connect_france_connect_particulier(@fci.user)
|
||||
else
|
||||
# TODO
|
||||
@email = sanitized_email_params
|
||||
@merge_token = merge_token_params
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,9 +3,17 @@ import { show, hide } from '@utils';
|
|||
export function showFusion() {
|
||||
show(document.querySelector('.fusion'));
|
||||
hide(document.querySelector('.new-account'));
|
||||
hide(document.querySelector('.new-account-password-confirmation'));
|
||||
}
|
||||
|
||||
export function showNewAccount() {
|
||||
hide(document.querySelector('.fusion'));
|
||||
show(document.querySelector('.new-account'));
|
||||
hide(document.querySelector('.new-account-password-confirmation'));
|
||||
}
|
||||
|
||||
export function showNewAccountPasswordConfirmation() {
|
||||
hide(document.querySelector('.fusion'));
|
||||
hide(document.querySelector('.new-account'));
|
||||
show(document.querySelector('.new-account-password-confirmation'));
|
||||
}
|
||||
|
|
|
@ -43,7 +43,8 @@ import {
|
|||
} from '../new_design/user-sign_up';
|
||||
import {
|
||||
showFusion,
|
||||
showNewAccount
|
||||
showNewAccount,
|
||||
showNewAccountPasswordConfirmation
|
||||
} from '../new_design/fc-fusion';
|
||||
|
||||
// This is the global application namespace where we expose helpers used from rails views
|
||||
|
@ -55,6 +56,7 @@ const DS = {
|
|||
showImportJustificatif,
|
||||
showFusion,
|
||||
showNewAccount,
|
||||
showNewAccountPasswordConfirmation,
|
||||
replaceSemicolonByComma,
|
||||
acceptEmailSuggestion,
|
||||
discardEmailSuggestionBox
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
%p
|
||||
Le compte #{email} existe déjà sur #{APPLICATION_NAME}
|
||||
%br
|
||||
entrez votre mot de passe pour fusionner les comptes
|
||||
|
||||
= form_tag france_connect_particulier_merge_with_existing_account_path, remote: true, class: 'mt-2 form' do
|
||||
= hidden_field_tag :merge_token, merge_token
|
||||
= hidden_field_tag :email, email
|
||||
= label_tag :password, 'Mot de passe (8 caractères minimum)'
|
||||
= password_field_tag :password, nil, autocomplete: 'current-password'
|
||||
= button_tag 'revenir en arrière', type: 'button', class: 'button secondary', onclick: 'DS.showNewAccount(event);'
|
||||
= submit_tag 'Fusionner les comptes', class: 'button primary'
|
|
@ -41,3 +41,4 @@
|
|||
= email_field_tag :email
|
||||
= submit_tag 'Utiliser ce mail', class: 'button primary'
|
||||
|
||||
.new-account-password-confirmation.hidden
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<%= render_to_element('.new-account-password-confirmation', partial: 'password_confirmation', locals: { email: @email, merge_token: @merge_token }) %>
|
||||
|
||||
DS.showNewAccountPasswordConfirmation();
|
|
@ -251,5 +251,22 @@ describe FranceConnect::ParticulierController, type: :controller do
|
|||
expect(response.body).to include("window.location.href='/'")
|
||||
end
|
||||
end
|
||||
|
||||
context 'when an account with the same email exists' do
|
||||
let!(:user) { create(:user, email: email) }
|
||||
|
||||
render_views
|
||||
|
||||
it 'asks for the corresponding password' do
|
||||
subject
|
||||
fci.reload
|
||||
|
||||
expect(fci.user).to be_nil
|
||||
expect(fci.merge_token).not_to be_nil
|
||||
expect(controller.current_user).to be_nil
|
||||
|
||||
expect(response.body).to include('entrez votre mot de passe')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue