Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Toast Messages for Bad Logins #1874

Merged
merged 3 commits into from
Jul 12, 2023

Conversation

rosenjcb
Copy link
Contributor

@rosenjcb rosenjcb commented Jul 8, 2023

Description

Right now if you try to login and you provide an unknown username/email or a wrong password, you will get no toast message. This PR adds toast messages for those scenarios and uses the messages already found in lemmy-translations.

Screenshots

image

Comment on lines 172 to 180
if (loginRes.msg === "couldnt_find_that_username_or_email") {
toast(
I18NextService.i18n.t("couldnt_find_that_username_or_email"),
"danger"
);
}
if (loginRes.msg === "password_incorrect") {
toast(I18NextService.i18n.t("password_incorrect"), "danger");
}
Copy link
Member

Choose a reason for hiding this comment

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

Should we be displaying different error messages for these? I would think letting potential attackers know which credential they got wrong is ill advised.

Copy link
Contributor Author

@rosenjcb rosenjcb Jul 8, 2023

Choose a reason for hiding this comment

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

It could be an attack vector - especially if there's no retry limit on failed password attempts. I can't seem to find a good generic error message that's already provided in lemmy-translations. Do you have a suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

Not off the top of my head. However, worth pointing out is that even if we change the toast on the frontend, the response from the server still has distinct message for each case, so there will need to be a backend change as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

If the backend response login_res is already spilling the beans, then it doesn’t matter much whether we use unique error toasters or not. The attack vector will still be present.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I see you already mentioned that @SleeplessOne1917. I need to read better before commenting.

Copy link
Contributor Author

@rosenjcb rosenjcb Jul 8, 2023

Choose a reason for hiding this comment

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

@SleeplessOne1917 This is what I can do.

1.) Make a PR on lemmy-translations to add a new entry {"incorrect_login": "Incorrect login credentials"}
2.) Make a PR on lemmy to swap out the API response with this new generic entry instead of couldnt_find_that_username_or_email and password_correct.
3.) Update this PR to reflect the changes once they've been merged.

Would that work?

Copy link
Member

Choose a reason for hiding this comment

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

@rosenjcb sounds good!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great I have LemmyNet/lemmy#3549 and LemmyNet/lemmy-translations#83 set up. The code change isn't covered by tests though, so it's probably safe for someone to check out the change and run it locally before merging.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for the attention to security on this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The two PRs above were approved and merged. I went ahead and swapped the condition check + toast response to use the generic incorrect_login string. Thanks for the feedback and support!

@dessalines dessalines merged commit 7a804ff into LemmyNet:main Jul 12, 2023
1 check passed
andrewstuart added a commit to andrewstuart/lemmy-ui that referenced this pull request Jul 13, 2023
Handle errors from sharp

Revert "Handle errors from sharp"

This reverts commit 70f6268.

Handle any sharp errors gracefully

Add Toast Messages for Bad Logins (LemmyNet#1874)

* Added toast prompts

* Using generic  message instead.

---------

Co-authored-by: Jacob Rosenzweig <rosenjcb@Jacobs-MacBook-Pro.local>
Co-authored-by: SleeplessOne1917 <abias1122@gmail.com>

Fix CSP in dev mode (LemmyNet#1918)

Remove invalid default option from language list (LemmyNet#1919)

Set person_id to myId in handleLeaveModTeam (LemmyNet#1929)
dessalines pushed a commit that referenced this pull request Jul 21, 2023
* Added toast prompts

* Using generic  message instead.

---------

Co-authored-by: Jacob Rosenzweig <rosenjcb@Jacobs-MacBook-Pro.local>
Co-authored-by: SleeplessOne1917 <abias1122@gmail.com>
andrewstuart added a commit to andrewstuart/lemmy-ui that referenced this pull request Jul 24, 2023
Handle errors from sharp

Revert "Handle errors from sharp"

This reverts commit 70f6268.

Handle any sharp errors gracefully

Add Toast Messages for Bad Logins (LemmyNet#1874)

* Added toast prompts

* Using generic  message instead.

---------

Co-authored-by: Jacob Rosenzweig <rosenjcb@Jacobs-MacBook-Pro.local>
Co-authored-by: SleeplessOne1917 <abias1122@gmail.com>

Fix CSP in dev mode (LemmyNet#1918)

Remove invalid default option from language list (LemmyNet#1919)

Set person_id to myId in handleLeaveModTeam (LemmyNet#1929)
andrewstuart added a commit to andrewstuart/lemmy-ui that referenced this pull request Jul 27, 2023
Handle errors from sharp

Revert "Handle errors from sharp"

This reverts commit 70f6268.

Handle any sharp errors gracefully

Add Toast Messages for Bad Logins (LemmyNet#1874)

* Added toast prompts

* Using generic  message instead.

---------

Co-authored-by: Jacob Rosenzweig <rosenjcb@Jacobs-MacBook-Pro.local>
Co-authored-by: SleeplessOne1917 <abias1122@gmail.com>

Fix CSP in dev mode (LemmyNet#1918)

Remove invalid default option from language list (LemmyNet#1919)

Set person_id to myId in handleLeaveModTeam (LemmyNet#1929)
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.

None yet

5 participants