Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fdb4d40
changelog: Upcoming Features, Account reset, Dont let account reset f…
mdiarra3 Feb 27, 2024
ae6f163
rubocop
mdiarra3 Feb 27, 2024
69947d4
Merge remote-tracking branch 'origin/main' into LG-11784-deletion-req…
mdiarra3 Feb 28, 2024
f5b0910
login options presenter
mdiarra3 Feb 28, 2024
c495263
pending controller specs
mdiarra3 Feb 29, 2024
b5765c5
Account Reset spec
mdiarra3 Feb 29, 2024
d30a086
update pending specs
mdiarra3 Feb 29, 2024
122ca70
Merge remote-tracking branch 'origin/main' into LG-11784-deletion-req…
mdiarra3 Mar 1, 2024
8e709a4
LG-11784: users will see over again
mdiarra3 Mar 4, 2024
5450aa3
fix spec
mdiarra3 Mar 4, 2024
7c9cf4e
spanish and french
mdiarra3 Mar 4, 2024
b94920f
normalize_yaml
mdiarra3 Mar 5, 2024
879c1f0
use nil instead of 0 for check
mdiarra3 Mar 5, 2024
9e080d1
change to use specific hours rather than whether featuere is on
mdiarra3 Mar 5, 2024
735dea4
refactor account reset concern
mdiarra3 Mar 5, 2024
14d28d8
fraud period
mdiarra3 Mar 5, 2024
ab85187
fix concern
mdiarra3 Mar 5, 2024
82defd1
account reset concern fix
mdiarra3 Mar 5, 2024
906d914
fix user mailer
mdiarra3 Mar 5, 2024
00480e5
use the reset concern in pending presenter
mdiarra3 Mar 6, 2024
fbea98a
pending presenter spec
mdiarra3 Mar 6, 2024
30a994a
en
mdiarra3 Mar 7, 2024
1c9a9c2
normalize_yaml
mdiarra3 Mar 11, 2024
c8398d1
Merge remote-tracking branch 'origin/main' into LG-11784-deletion-req…
mdiarra3 Mar 11, 2024
346dd87
make sure to use proper naming
mdiarra3 Mar 11, 2024
c9da687
move over to grant request
mdiarra3 Mar 13, 2024
34db876
grant request
mdiarra3 Mar 13, 2024
d24655d
change method to work
mdiarra3 Mar 13, 2024
53dc2c6
commenting presenter to use proper language
mdiarra3 Mar 18, 2024
9f030ae
add spec for grant request
mdiarra3 Mar 18, 2024
0a92576
leverage reset concern
mdiarra3 Mar 20, 2024
add48a3
Merge remote-tracking branch 'origin/main' into LG-11784-deletion-req…
mdiarra3 Mar 21, 2024
d083a72
Add spec for find pending request fraud check
mdiarra3 Mar 21, 2024
5eb1029
make sure second step can handle the new step language
mdiarra3 Mar 22, 2024
bc9e831
LG-11784: add check for when wait period for fraud isnt set
mdiarra3 Mar 22, 2024
bfdaa9e
Regular wait period check for fraud users resetting
mdiarra3 Mar 22, 2024
dfd065f
Add spec checks for when account reset is nil
mdiarra3 Mar 22, 2024
c548109
Merge remote-tracking branch 'origin/main' into LG-11784-deletion-req…
mdiarra3 Mar 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions app/controllers/account_reset/pending_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module AccountReset
class PendingController < ApplicationController
include UserAuthenticator
include ActionView::Helpers::DateHelper
include AccountResetConcern

before_action :authenticate_user
before_action :confirm_account_reset_request_exists
Expand Down Expand Up @@ -32,16 +32,5 @@ def pending_account_reset_request
current_user,
).call
end

def account_reset_deletion_period_interval
current_time = Time.zone.now

distance_of_time_in_words(
current_time,
current_time + IdentityConfig.store.account_reset_wait_period_days.days,
true,
accumulate_on: :hours,
)
end
end
end
13 changes: 1 addition & 12 deletions app/controllers/account_reset/request_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module AccountReset
class RequestController < ApplicationController
include TwoFactorAuthenticatable
include ActionView::Helpers::DateHelper
include AccountResetConcern

before_action :confirm_two_factor_enabled

Expand Down Expand Up @@ -41,16 +41,5 @@ def analytics_attributes
email_addresses: current_user.email_addresses.count,
}
end

def account_reset_deletion_period_interval
current_time = Time.zone.now

distance_of_time_in_words(
current_time,
current_time + IdentityConfig.store.account_reset_wait_period_days.days,
true,
accumulate_on: :hours,
)
end
end
end
35 changes: 35 additions & 0 deletions app/controllers/concerns/account_reset_concern.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module AccountResetConcern
include ActionView::Helpers::DateHelper
def account_reset_deletion_period_interval
current_time = Time.zone.now

distance_of_time_in_words(
current_time,
current_time + account_reset_wait_period_days,
true,
accumulate_on: reset_accumulation_type,
)
end

def account_reset_wait_period_days
if supports_fraud_account_reset?
IdentityConfig.store.account_reset_fraud_user_wait_period_days.days
else
IdentityConfig.store.account_reset_wait_period_days.days
end
end

def supports_fraud_account_reset?
(current_user.fraud_review_pending? ||
current_user.fraud_rejection?) &&
(IdentityConfig.store.account_reset_fraud_user_wait_period_days.present? )
Comment thread
mdiarra3 marked this conversation as resolved.
Outdated
end

def reset_accumulation_type
Comment thread
mdiarra3 marked this conversation as resolved.
Outdated
if account_reset_wait_period_days > 3
:days
else
:hours
end
end
end
30 changes: 24 additions & 6 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def personal_key_regenerated
def account_reset_request(account_reset)
with_user_locale(user) do
@token = account_reset&.request_token
@account_reset_deletion_period_hours = account_reset_deletion_period_hours
@account_reset_deletion_period_interval = account_reset_deletion_period_interval
@header = t(
'user_mailer.account_reset_request.header',
interval: account_reset_deletion_period_interval,
Expand All @@ -160,7 +160,7 @@ def account_reset_granted(account_reset)
with_user_locale(user) do
@token = account_reset&.request_token
@granted_token = account_reset&.granted_token
@account_reset_deletion_period_hours = account_reset_deletion_period_hours
@account_reset_deletion_period_interval = account_reset_deletion_period_interval
@account_reset_token_valid_period = account_reset_token_valid_period
mail(
to: email_address.email,
Expand Down Expand Up @@ -436,14 +436,24 @@ def account_reset_deletion_period_interval

distance_of_time_in_words(
current_time,
current_time + IdentityConfig.store.account_reset_wait_period_days.days,
current_time + account_reset_wait_period_days,
true,
accumulate_on: :hours,
accumulate_on: reset_accumulation_type,
)
end

def account_reset_deletion_period_hours
IdentityConfig.store.account_reset_wait_period_days.days.in_hours.to_i
def account_reset_wait_period_days
Comment thread
mdiarra3 marked this conversation as resolved.
Outdated
if supports_fraud_account_reset?
IdentityConfig.store.account_reset_fraud_user_wait_period_days.days
else
IdentityConfig.store.account_reset_wait_period_days.days
end
end

def supports_fraud_account_reset?
(user.fraud_review_pending? ||
user.fraud_rejection?) &&
(IdentityConfig.store.account_reset_fraud_user_wait_period_days.present?)
end

def account_reset_token_valid_period
Expand All @@ -456,4 +466,12 @@ def account_reset_token_valid_period
accumulate_on: :hours,
)
end

def reset_accumulation_type
if account_reset_wait_period_days > 3
:days
else
:hours
end
end
end
39 changes: 36 additions & 3 deletions app/presenters/account_reset/pending_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(account_reset_request)
end

def time_remaining_until_granted(now: Time.zone.now)
wait_time = IdentityConfig.store.account_reset_wait_period_days.days
wait_time = account_reset_wait_period_days

distance_of_time_in_words(
now,
Expand All @@ -19,8 +19,41 @@ def time_remaining_until_granted(now: Time.zone.now)
)
end

def account_reset_deletion_period_hours
IdentityConfig.store.account_reset_wait_period_days.days.in_hours.to_i
def account_reset_deletion_period
Comment thread
mdiarra3 marked this conversation as resolved.
current_time = Time.zone.now

distance_of_time_in_words(
current_time,
current_time + account_reset_wait_period_days,
true,
accumulate_on: reset_accumulation_type,
)
end

def account_reset_wait_period_days
if supports_fraud_account_reset?
IdentityConfig.store.account_reset_fraud_user_wait_period_days.days
else
IdentityConfig.store.account_reset_wait_period_days.days
end
end

def supports_fraud_account_reset?
(account_reset_request_user.fraud_review_pending? ||
account_reset_request_user.fraud_rejection?) &&
(IdentityConfig.store.account_reset_fraud_user_wait_period_days.present?)
end

def account_reset_request_user
account_reset_request.user
end

def reset_accumulation_type
if account_reset_wait_period_days > 3
Comment thread
mdiarra3 marked this conversation as resolved.
Outdated
:days
else
:hours
end
end
end
end
16 changes: 15 additions & 1 deletion app/presenters/two_factor_login_options_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,23 @@ def account_reset_deletion_period_interval

view.distance_of_time_in_words(
current_time,
current_time + IdentityConfig.store.account_reset_wait_period_days.days,
current_time + account_reset_wait_period_days,
true,
accumulate_on: :hours,
)
end

def account_reset_wait_period_days
Comment thread
mdiarra3 marked this conversation as resolved.
Outdated
if supports_fraud_account_reset?
IdentityConfig.store.account_reset_fraud_user_wait_period_days.days
else
IdentityConfig.store.account_reset_wait_period_days.days
end
end

def supports_fraud_account_reset?
(user.fraud_review_pending? ||
user.fraud_rejection?) &&
(IdentityConfig.store.account_reset_fraud_user_wait_period_days.present?)
end
end
13 changes: 13 additions & 0 deletions app/services/account_reset/grant_requests_and_send_emails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def perform(now)
sql_query_for_users_eligible_to_delete_their_accounts,
tvalue: now - IdentityConfig.store.account_reset_wait_period_days.days,
).order('requested_at ASC').each do |arr|
next if fraud_wait_period_not_met?(arr, now)
notifications_sent += 1 if grant_request_and_send_email(arr)
end

Expand Down Expand Up @@ -48,5 +49,17 @@ def grant_request_and_send_email(arr)
end
true
end

def fraud_wait_period_not_met?(arr, now)
Comment thread
mdiarra3 marked this conversation as resolved.
Outdated
if (arr.user.fraud_review_pending? ||
arr.user.fraud_rejection?) &&
(fraud_wait_period_days > 0)
return arr.requested_at > (now - fraud_wait_period_days)
end
end

def fraud_wait_period_days
IdentityConfig.store.account_reset_fraud_user_wait_period_days.days
Comment thread
mdiarra3 marked this conversation as resolved.
Outdated
end
end
end
2 changes: 1 addition & 1 deletion app/views/account_reset/pending/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<p>
<%= t(
'account_reset.pending.wait_html',
hours: @pending_presenter.account_reset_deletion_period_hours,
waiting_period: @pending_presenter.account_reset_deletion_period,
interval: @pending_presenter.time_remaining_until_granted,
) %>
</p>
Expand Down
2 changes: 1 addition & 1 deletion app/views/user_mailer/account_reset_granted.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p class="lead">
<%= t('user_mailer.account_reset_granted.intro_html', hours: @account_reset_deletion_period_hours, app_name: link_to(APP_NAME, IdentityConfig.store.mailer_domain_name, class: 'gray')) %>
<%= t('user_mailer.account_reset_granted.intro_html', waiting_period: @account_reset_deletion_period_interval, app_name: link_to(APP_NAME, IdentityConfig.store.mailer_domain_name, class: 'gray')) %>
</p>

<table class="button expanded large">
Expand Down
2 changes: 1 addition & 1 deletion app/views/user_mailer/account_reset_request.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p class="lead">
<%= t('user_mailer.account_reset_request.intro_html', app_name: link_to(APP_NAME, IdentityConfig.store.mailer_domain_name, class: 'gray'), hours: @account_reset_deletion_period_hours) %>
<%= t('user_mailer.account_reset_request.intro_html', app_name: link_to(APP_NAME, IdentityConfig.store.mailer_domain_name, class: 'gray'), waiting_period: @account_reset_deletion_period_interval) %>
</p>

<p class="lead">
Expand Down
2 changes: 2 additions & 0 deletions config/application.yml.default
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ all_redirect_uris_cache_duration_minutes: 2
allowed_ialmax_providers: '[]'
allowed_verified_within_providers: '[]'
account_reset_token_valid_for_days: 1
account_reset_fraud_user_wait_period_days:
account_reset_wait_period_days: 1
account_suspended_support_code: EFGHI
acuant_assure_id_password: ''
Expand Down Expand Up @@ -507,6 +508,7 @@ production:
test:
aamva_private_key: 123abc
aamva_public_key: 123abc
account_reset_fraud_user_wait_period_days: 30
acuant_assure_id_url: https://example.com
acuant_facial_match_url: https://facial_match.example.com
acuant_passlive_url: https://liveness.example.com
Expand Down
4 changes: 2 additions & 2 deletions config/locales/account_reset/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ en:
confirm: If you cancel now, you must create a new request and wait another
%{interval} to delete your account.
header: You requested to delete your account
wait_html: There is a %{hours}-hour waiting period to delete your account. In
<strong>%{interval}</strong>, you will receive an email with
wait_html: There is a %{waiting_period} waiting period to delete your account.
Comment thread
mdiarra3 marked this conversation as resolved.
Outdated
In <strong>%{interval}</strong>, you will receive an email with
instructions to complete the deletion.
recovery_options:
check_saved_credential: See if you have a saved credential
Expand Down
6 changes: 3 additions & 3 deletions config/locales/account_reset/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ es:
confirm: Si cancela ahora, debe crear una nueva solicitud y esperar otras
%{interval} para eliminar su cuenta.
header: Solicitaste eliminar tu cuenta
wait_html: Hay un período de espera de %{hours} horas para eliminar su cuenta.
En <strong>%{interval}</strong>, recibirá un correo electrónico con
instrucciones para completar la eliminación.
wait_html: Hay un período de espera de %{waiting_period} para eliminar su
cuenta. En <strong>%{interval}</strong>, recibirá un correo electrónico
con instrucciones para completar la eliminación.
recovery_options:
check_saved_credential: Verifica si tienes una credencial almacenada
check_webauthn_platform_info: Si has habilitado el desbloqueo facial o táctil,
Expand Down
2 changes: 1 addition & 1 deletion config/locales/account_reset/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fr:
confirm: Si vous annulez maintenant, vous devez créer une nouvelle demande et
attendre encore %{interval} pour supprimer votre compte.
header: Vous avez demandé de supprimer votre compte
wait_html: Il y a un délai d’attente de %{hours} heures pour supprimer votre
wait_html: Il y a un délai d’attente de %{waiting_period} pour supprimer votre
compte. Dans <strong>%{interval}</strong>, vous recevrez un e-mail avec
des instructions pour terminer la suppression.
recovery_options:
Expand Down
19 changes: 10 additions & 9 deletions config/locales/user_mailer/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ en:
button: Yes, continue deleting
cancel_link_text: please cancel
help_html: If you don’t want to delete your account, %{cancel_account_reset_html}.
intro_html: Your %{hours} hour waiting period has ended. Please complete step 2
of the process.<br><br> If you’ve been unable to locate your
intro_html: Your %{waiting_period} waiting period has ended. Please complete
step 2 of the process.<br><br> If you’ve been unable to locate your
authentication methods, select “confirm deletion” to delete your
%{app_name} account.<br><br> In the future, if you need to access
participating government websites who use %{app_name}, you can create a
Expand All @@ -33,13 +33,14 @@ en:
to cancel.
header: Your account will be deleted in %{interval}
intro_html: 'As a security measure, %{app_name} requires a two-step process to
delete your account:<br><br> Step One: There is a %{hours} hour waiting
period if you have lost access to your authentication methods and need
to delete your account. If you locate your authentication methods, you
can sign in to your %{app_name} account to cancel this request.<br><br>
Step Two: After your %{hours} hour waiting period, you will receive an
email that will ask you to confirm the deletion of your %{app_name}
account. Your account will not be deleted until you confirm.'
delete your account:<br><br> Step One: There is a %{waiting_period}
waiting period if you have lost access to your authentication methods
Comment thread
mdiarra3 marked this conversation as resolved.
Outdated
and need to delete your account. If you locate your authentication
methods, you can sign in to your %{app_name} account to cancel this
request.<br><br> Step Two: After your %{waiting_period} waiting period,
you will receive an email that will ask you to confirm the deletion of
your %{app_name} account. Your account will not be deleted until you
confirm.'
subject: How to delete your %{app_name} account
account_verified:
change_password_link: change your password
Expand Down
10 changes: 5 additions & 5 deletions config/locales/user_mailer/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ es:
button: Sí, continúa eliminando
cancel_link_text: por favor cancele
help_html: Si no desea eliminar su cuenta, %{cancel_account_reset_html}.
intro_html: Su período de espera de %{hours} horas ha finalizado. Complete el
intro_html: Su período de espera de %{waiting_period} ha finalizado. Complete el
paso 2 del proceso.<br><br>Si no ha podido localizar sus métodos de
autenticación, seleccione “confirmar eliminación” para eliminar su
cuenta de %{app_name}.<br><br> En el futuro, si necesita acceder a los
Expand All @@ -36,13 +36,13 @@ es:
header: Su cuenta será eliminada en %{interval}
intro_html: 'Como medida de seguridad, %{app_name} requiere un proceso de dos
pasos para eliminar su cuenta:<br><br> Paso uno: hay un período de
espera de %{hours} horas si ha perdido el acceso a sus métodos de
espera de %{waiting_period} si ha perdido el acceso a sus métodos de
autenticación y necesita eliminar su cuenta. Si encuentra sus métodos de
autenticación, puede iniciar sesión en su cuenta %{app_name} para
cancelar esta solicitud.<br><br> Paso dos: Después de su período de
espera de %{hours} horas, recibirá un correo electrónico que le pedirá
que confirme la eliminación de su cuenta %{app_name}. Su cuenta no se
eliminará hasta que confirme.'
espera de %{waiting_period}, recibirá un correo electrónico que le
pedirá que confirme la eliminación de su cuenta %{app_name}. Su cuenta
no se eliminará hasta que confirme.'
subject: Cómo eliminar su cuenta de %{app_name}
account_verified:
change_password_link: cambiar tu contraseña
Expand Down
Loading