-
-
Notifications
You must be signed in to change notification settings - Fork 884
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
Show deny reason to users after a failed login. Fixes #2191 #2206
Conversation
crates/api_common/src/lib.rs
Outdated
if registration.deny_reason.is_some() { | ||
return Err(LemmyError::from_message("registration_denied")); | ||
if let Some(deny_reason) = registration.deny_reason { | ||
return Err(LemmyError::from_message(&deny_reason)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the deny reasons i see on lemmy.ml are really short, eg "Not an answer". Its going to be very confusing if that is shown as an error message after login. So this should have some message such as: "Registration denied: {{deny_reason}}".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could add that, but it wouldn't be i18n compatible, it'd be always english. This is because the front end, if it can't find that i18n string, just outputs the whole text. So since it can't find the string : "registration_denied: X reason here", it would always be in english.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean do the localization on the backend, same way we do for email.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not fully familiar with how this works. In this build.rs, I'd need to add a 2nd src file with all those languages? Seems like there might be a namespace type conflict?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just add it to the same translation file we use for email, even if that makes the name accurate. So just add your string to the existing en.json and it should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K done.
cbcf8e1
to
163284b
Compare
163284b
to
aa39018
Compare
I tested this and it works, correctly shows the deny reason if you try to login.