Skip to content

Commit

Permalink
feat(mon-pix): don't leak anymore that an account doesn't exist
Browse files Browse the repository at this point in the history
The root of leak is in the API and must be fixed in the API.
  • Loading branch information
lego-technix committed Oct 23, 2024
1 parent 209dbc2 commit e87aef8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,11 @@ export default class PasswordResetDemandForm extends Component {
method: 'POST',
body: JSON.stringify({ email }),
});
if (response.status == 404) {
this.errorMessage = this.intl.t('components.authentication.password-reset-demand-form.404-message');
} else if (!response.ok) {
if (!response.ok && response.status != 404) {
throw new Error(`Response status: ${response.status}`);
} else {
this.isPasswordResetDemandReceived = true;
}

this.isPasswordResetDemandReceived = true;
} catch (error) {
this.errorMessage = this.intl.t('common.api-error-messages.internal-server-error');
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ module('Integration | Component | Authentication | password-reset-demand-form',
});
});

// TODO: This test module will need to be removed when the API doesn't leak anymore that an account doesn't exist with a "404 Not Found".
module('when there is no corresponding user account', function () {
test('it displays an "account not found" error message', async function (assert) {
test('it also doesn’t display any error message and displays a "password reset demand received" info', async function (assert) {
// given
window.fetch.resolves(
fetchMock({
Expand All @@ -138,9 +139,15 @@ module('Integration | Component | Authentication | password-reset-demand-form',
);

// then
// The following doesn’t work because of a PixUi span inside the role element
//assert.dom(screen.queryByRole('alert', { name: t('pages.password-reset-demand.error.message') })).exists();
assert.dom(screen.queryByText(t('components.authentication.password-reset-demand-form.404-message'))).exists();
assert.dom(screen.queryByRole('alert')).doesNotExist();

assert
.dom(
screen.queryByRole('heading', {
name: t('components.authentication.password-reset-demand-received-info.heading'),
}),
)
.exists();
});
});

Expand Down
1 change: 0 additions & 1 deletion mon-pix/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@
"signup-heading": "Other ways to sign up"
},
"password-reset-demand-form": {
"404-message": "The email address entered does not match any Pix account",
"actions": {
"receive-reset-button": "Receive a reset link"
},
Expand Down
1 change: 0 additions & 1 deletion mon-pix/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@
}
},
"password-reset-demand-form": {
"404-message": "Esta dirección de correo electrónico no corresponde a ninguna cuenta",
"rule": "All fields are required.",
"no-email-question": "No email address?",
"contact-us-link": {
Expand Down
1 change: 0 additions & 1 deletion mon-pix/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@
"signup-heading": "Autres moyens d’inscription"
},
"password-reset-demand-form": {
"404-message": "Cette adresse e-mail ne correspond à aucun compte",
"actions": {
"receive-reset-button": "Recevoir un lien de réinitialisation"
},
Expand Down
1 change: 0 additions & 1 deletion mon-pix/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@
}
},
"password-reset-demand-form": {
"404-message": "Dit e-mailadres komt niet overeen met een account",
"rule": "All fields are required.",
"no-email-question": "No email address?",
"contact-us-link": {
Expand Down

0 comments on commit e87aef8

Please sign in to comment.