Skip to content

LG-6885: Remind users about backup codes & regenerate#6723

Merged
jc-gsa merged 17 commits intomainfrom
lg-6885-backup-code-reminder-regenerate
Aug 17, 2022
Merged

LG-6885: Remind users about backup codes & regenerate#6723
jc-gsa merged 17 commits intomainfrom
lg-6885-backup-code-reminder-regenerate

Conversation

@jc-gsa
Copy link
Contributor

@jc-gsa jc-gsa commented Aug 10, 2022

No description provided.

Comment on lines +125 to +126
event_type: ['sign_in_before_2fa',
'sign_in_after_2fa'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're including sign_in_after_2fa, do we need to include sign_in_before_2fa?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I questioned that myself. As the method is named second_last_signed_in_at I figured I'd keep it generic as possible and count both events. Open to other suggestions.

I find the name second_last_signed_in_at somewhat awkward, but found it necessary for a currently signed in user. Maybe the wording can be changed. Otherwise a method like last_signed_in_at returns the current login date for the current_user.

Copy link
Contributor Author

@jc-gsa jc-gsa Aug 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These columns were previously dropped from the User table when Devise's trackable module was removed, I believe: https://gsa-tts.slack.com/archives/C0NGESUN5/p1649098117066389

I guess that had the distinction:
current_sign_in_at vs. last_sign_in_at

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, they were unused (and duplicative of events), so I think it's fine to use events. I don't mind the naming, I think it's clear and explicit 🙂

When someone signs in, they will create both a sign_in_before_2fa and sign_in_after_2fa event, but I'm not sure if that means the 2nd most recent event will likely always be within the last few minutes. If it does, that's probably a decent enough reason to drop sign_in_before_2fa from the query?

<%= @presenter.body_info %>
</p>

<div class="col-12">
Copy link
Contributor

@aduth aduth Aug 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen this col-12 make an appearance quite often in recent months. col-12 is a remnant from Basscss which was removed quite a while ago. It seems redundant anyways, since it just assigns width: 100%, which would be the default for a block-level <div> element.

Can we just remove the wrapper?

Suggested change
<div class="col-12">

def second_last_signed_in_at
user.events.where(
event_type: 'sign_in_after_2fa'
).order(id: :desc).pluck(:created_at).second
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
).order(id: :desc).pluck(:created_at).second
).order(created_at: :desc).pluck(:created_at).second

I think created_at is preferable for the sort, and we already have an index on (user_id, created_at) as a bonus.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During testing, I think I had some specific reason for preferring id. This has been changed.

@@ -0,0 +1,21 @@
class BackupCodeReminderPresenter
Copy link
Contributor

@mitchellhenke mitchellhenke Aug 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of dropping the presenter and putting the I18n calls directly in the template? In the case where we only have content in the presenter, I think it would be good to skip a layer of abstraction.

@jc-gsa jc-gsa force-pushed the lg-6885-backup-code-reminder-regenerate branch 2 times, most recently from 86716a9 to 9ff9629 Compare August 16, 2022 15:35
@jc-gsa jc-gsa force-pushed the lg-6885-backup-code-reminder-regenerate branch from 9ff9629 to ab336c3 Compare August 16, 2022 15:43
jc-gsa added 3 commits August 16, 2022 09:07
changelog: Internal, Authentication, Add backup code reminder MFA (LG-6885)
@jc-gsa jc-gsa requested a review from a team August 16, 2022 21:38
Copy link
Contributor

@jmdembe jmdembe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏾

Copy link
Contributor

@mitchellhenke mitchellhenke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple comments, otherwise looks good!

Comment on lines +20 to +21
mfa_user = MfaContext.new(current_user)
mfa_user.backup_code_configurations.present?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mfa_user = MfaContext.new(current_user)
mfa_user.backup_code_configurations.present?
MfaContext.new(current_user).backup_code_configurations.present?

Comment on lines +119 to +122
def last_signed_in_at
user.devices.order(last_used_at: :desc).first&.last_used_at
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def last_signed_in_at
user.devices.order(last_used_at: :desc).first&.last_used_at
end

It looks like this isn't used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this isn't used. It can be removed. I originally included it because it seemed odd to have a method for second_last_signed_in_at but no method for last_signed_in_at.

Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test approve after requested changes

@jc-gsa jc-gsa merged commit 9070c33 into main Aug 17, 2022
@jc-gsa jc-gsa deleted the lg-6885-backup-code-reminder-regenerate branch August 17, 2022 21:49
@jc-gsa jc-gsa restored the lg-6885-backup-code-reminder-regenerate branch August 29, 2022 23:12
@jc-gsa jc-gsa deleted the lg-6885-backup-code-reminder-regenerate branch December 26, 2024 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants