-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LG-15177 Add a CTA to return to an SP after entering a verify-by-mail…
… code (#11602) In #11591 we added a `post_idv_follow_up_url` that allows users to return to a service provider after finishing verification out-of-band. This commit puts this new URL to work in the verify-by-mail code. After this commit users who enter a verify-by-mail code without an SP in their session will see a new SP follow-up screen. This screen includes a CTA that prompts the user to connect their account to the service provider they started proofing with. This link leads to the new post-IdV follow-up URL. changelog: User-Facing Improvements, Verify-by-mail, A CTA was added to prompt users to return to the service provider after verify-by-mail
- Loading branch information
Showing
14 changed files
with
436 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# frozen_string_literal: true | ||
|
||
module Idv | ||
module ByMail | ||
class SpFollowUpController < ApplicationController | ||
include Idv::AvailabilityConcern | ||
|
||
before_action :confirm_two_factor_authenticated | ||
before_action :confirm_needs_sp_follow_up | ||
|
||
def new | ||
analytics.track_event(:idv_by_mail_sp_follow_up_visited, **analytics_params) | ||
@presenter = Idv::ByMail::SpFollowUpPresenter.new(current_user:) | ||
end | ||
|
||
def show | ||
analytics.track_event(:idv_by_mail_sp_follow_up_submitted, **analytics_params) | ||
|
||
sp_return_url_resolver = SpReturnUrlResolver.new( | ||
service_provider: current_user.active_profile.initiating_service_provider, | ||
) | ||
redirect_url = sp_return_url_resolver.post_idv_follow_up_url || | ||
sp_return_url_resolver.return_to_sp_url | ||
redirect_to(redirect_url, allow_other_host: true) | ||
end | ||
|
||
def cancel | ||
analytics.track_event(:idv_by_mail_sp_follow_up_cancelled, **analytics_params) | ||
redirect_to account_url | ||
end | ||
|
||
private | ||
|
||
def analytics_params | ||
initiating_service_provider = current_user.active_profile.initiating_service_provider | ||
{ | ||
initiating_service_provider: initiating_service_provider.issuer, | ||
} | ||
end | ||
|
||
def confirm_needs_sp_follow_up | ||
return if current_user.identity_verified? && | ||
current_user.active_profile.initiating_service_provider.present? && | ||
!current_sp.present? | ||
redirect_to account_url | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
module Idv | ||
module ByMail | ||
class SpFollowUpPresenter | ||
include ActionView::Helpers::TranslationHelper | ||
|
||
attr_reader :current_user | ||
|
||
def initialize(current_user:) | ||
@current_user = current_user | ||
end | ||
|
||
def heading | ||
t( | ||
'idv.by_mail.sp_follow_up.heading', | ||
service_provider: initiating_service_provider_name, | ||
) | ||
end | ||
|
||
def body | ||
t( | ||
'idv.by_mail.sp_follow_up.body', | ||
service_provider: initiating_service_provider_name, | ||
app_name: APP_NAME, | ||
) | ||
end | ||
|
||
private | ||
|
||
def initiating_service_provider_name | ||
initiating_service_provider.friendly_name | ||
end | ||
|
||
def initiating_service_provider | ||
@initiating_service_provider ||= current_user.active_profile.initiating_service_provider | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<% self.title = @presenter.heading %> | ||
|
||
<div class="text-center"> | ||
<%= image_tag(asset_url('user-access.svg'), width: '280', height: '91', alt: '', aria: { hidden: true }) %> | ||
<h1 class="margin-bottom-4"><%= @presenter.heading %></h1> | ||
</div> | ||
|
||
<p><%= @presenter.body %></p> | ||
|
||
<div class='margin-top-5 margin-bottom-2'> | ||
<%= render ButtonComponent.new( | ||
url: idv_sp_follow_up_connect_path, | ||
big: true, | ||
wide: true, | ||
).with_content(t('idv.by_mail.sp_follow_up.connect_account')) %> | ||
</div> | ||
<div> | ||
<%= render ButtonComponent.new( | ||
url: idv_sp_follow_up_cancel_path, | ||
big: true, | ||
wide: true, | ||
outline: true, | ||
).with_content(t('idv.by_mail.sp_follow_up.go_to_account')) %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
spec/controllers/idv/by_mail/sp_follow_up_controller_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Idv::ByMail::SpFollowUpController do | ||
let(:post_idv_follow_up_url) { 'https://example.com/follow_up' } | ||
let(:initiating_service_provider) { create(:service_provider, post_idv_follow_up_url:) } | ||
let(:user) { create(:user, :fully_registered) } | ||
let!(:profile) { create(:profile, :active, user:, initiating_service_provider:) } | ||
|
||
before do | ||
stub_sign_in(user) if user.present? | ||
stub_analytics | ||
end | ||
|
||
describe '#new' do | ||
context 'the user has not finished verification' do | ||
let(:profile) do | ||
create(:profile, :verify_by_mail_pending, user:, initiating_service_provider:) | ||
end | ||
|
||
it 'redirects to the account page' do | ||
get :new | ||
|
||
expect(response).to redirect_to(account_url) | ||
end | ||
end | ||
|
||
context 'the user has an SP in the session' do | ||
before do | ||
allow(controller).to receive(:current_sp).and_return(initiating_service_provider) | ||
end | ||
|
||
it 'redirects to the account page' do | ||
get :new | ||
|
||
expect(response).to redirect_to(account_url) | ||
end | ||
end | ||
|
||
context 'the user does not have an initiating service provider' do | ||
let(:profile) { create(:profile, :active, user:, initiating_service_provider: nil) } | ||
|
||
it 'redirects to the account page' do | ||
get :new | ||
|
||
expect(response).to redirect_to(account_url) | ||
end | ||
end | ||
|
||
it 'logs analytics and renders the template' do | ||
get :new | ||
|
||
expect(response).to render_template(:new) | ||
expect(@analytics).to have_logged_event( | ||
:idv_by_mail_sp_follow_up_visited, | ||
initiating_service_provider: initiating_service_provider.issuer, | ||
) | ||
end | ||
end | ||
|
||
describe '#show' do | ||
it 'logs analytics and redirects to the service provider' do | ||
get :show | ||
|
||
expect(response).to redirect_to(post_idv_follow_up_url) | ||
expect(@analytics).to have_logged_event( | ||
:idv_by_mail_sp_follow_up_submitted, | ||
initiating_service_provider: initiating_service_provider.issuer, | ||
) | ||
end | ||
end | ||
|
||
describe '#cancel' do | ||
it 'logs analytics and redirects to the account URL' do | ||
get :cancel | ||
|
||
expect(response).to redirect_to(account_url) | ||
expect(@analytics).to have_logged_event( | ||
:idv_by_mail_sp_follow_up_cancelled, | ||
initiating_service_provider: initiating_service_provider.issuer, | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.