Skip to content

Commit

Permalink
Do not show My Account link within 2FA process (#664)
Browse files Browse the repository at this point in the history
**Why**: The link to My Account should only show
when the user has completed the full 2FA process.
  • Loading branch information
pkarman committed Nov 2, 2016
1 parent 44349df commit 9ba8389
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ApplicationController < ActionController::Base
rescue_from ActionController::InvalidAuthenticityToken,
with: :invalid_auth_token

helper_method :decorated_user, :reauthn?
helper_method :decorated_user, :reauthn?, :user_fully_authenticated?

prepend_before_action :session_expires_at
after_action :track_get_requests
Expand Down
7 changes: 4 additions & 3 deletions app/views/shared/_nav_auth.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ nav.bg-white
.sm-col-right.sm-right-align
div = t('shared.nav_auth.welcome', email: current_user.email)
.mt-12p.h6
= link_to t('shared.nav_auth.my_account'), profile_path,
class: current_page?(profile_path) ? 'bold gray' : 'underline'
span.px1.silver = '|'
- if user_fully_authenticated?
= link_to t('shared.nav_auth.my_account'), profile_path,
class: current_page?(profile_path) ? 'bold gray' : 'underline'
span.px1.silver = '|'
= link_to t('links.sign_out'), destroy_user_session_path, class: 'underline'
22 changes: 21 additions & 1 deletion spec/views/shared/_nav_auth.html.slim_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
before do
@user = build_stubbed(:user, :signed_up)
allow(view).to receive(:current_user).and_return(@user)
allow(view).to receive(:signed_in?).and_return(true)
allow(view).to receive(:user_fully_authenticated?).and_return(true)
end

it 'contains welcome message' do
Expand All @@ -14,10 +14,30 @@
expect(rendered).to have_content "Welcome #{@user.email}"
end

it 'contains link to my account' do
render

expect(rendered).to have_link(t('shared.nav_auth.my_account'), href: profile_path)
end

it 'contains sign out link' do
render

expect(rendered).to have_link(t('links.sign_out'), href: destroy_user_session_path)
end
end

context 'user has entered password but not complete 2fa' do
before do
@user = build_stubbed(:user, :signed_up)
allow(view).to receive(:current_user).and_return(@user)
allow(view).to receive(:user_fully_authenticated?).and_return(false)
end

it 'does not contain link to my account' do
render

expect(rendered).to_not have_link(t('shared.nav_auth.my_account'), href: profile_path)
end
end
end

0 comments on commit 9ba8389

Please sign in to comment.