zulip-mobile
zulip-mobile copied to clipboard
Handle new USER_DEACTIVATED and REALM_DEACTIVATED API error codes.
https://github.com/zulip/zulip/pull/17872 adds a couple of new custom error codes for errors that I'd expect us to see when trying to connect to a deactivated organization with the mobile apps (and also will change the error codes to 403).
We should check if these help the mobile app do better error handling for this error when trying to login or start the app.
Whats about if the implementation will be something like given below
Description |
Layout |
|---|---|
| If User logged In with realm and either realm or user account is deactivated then app will open with this Account-Pick screen to either choose a valid account or add a new account | ![]() |
| While adding new realm if realm is deactivated | ![]() |
| And same will be while authentication when user will try to login with user password then he would get Account deactivated error. |
Yes, I think this should help us do better error handling when trying to login. In particular, this is our error handling when doing a password login:
try {
const fetchedKey = await api.fetchApiKey({ realm, apiKey: '', email }, email, password);
this.setState({ progress: false });
dispatch(loginSuccess(realm, fetchedKey.email, fetchedKey.api_key));
} catch (err) {
this.setState({
progress: false,
error: requireEmailFormat
? 'Wrong email or password. Try again.'
: 'Wrong username or password. Try again.',
});
}
I think we could helpfully inspect err to see if it's one of those new errors, before the existing setState. And if it's one of those, set the React state with an appropriate error message instead of what it's currently being set to.
Let's start with that, before looking at changes like those in @vaibhavs2's message. The reasons I'm not inclined to pursue those are,
- Remembering the deactivated state client-side (necessary for the first screenshot) is more than the new API is asking us to do. Could easily get complicated with requirements like doing the right thing when an account/realm is re-activated, if that can happen
- For the second screenshot, I'm not sure we get
REALM_DEACTIVATEDon requesting/server_settings; my impression (from reading the linked PR a bit) is that the two errors are only given when you're trying to connect as a particular authenticated user, which we're not at that point in the UI.
I'd be happy to see a PR that made the logging-in improvement I described in my previous message. 🙂
Also, though, @timabbott, my understanding is we'll receive these errors on any authenticated request, right, not just when logging in? So POST /register, GET /events, etc.
If that's right, we can probably also be helpful by showing an alert with a message specific to these errors, alongside the code that forces a logout when we get a 4xx response. That's the two dispatch(logout()) sites that aren't in ProfileScreen (that one is for the user initiating a logout with a button).
@chrisbobbe that is correct, these error codes appear when failing authentication with your API key, in addition to when you fail to get an API key due to deactivated accounts/realms.
I should also add, that when sending messages to a group that includes a deactivated user one gets an infinite "sending" gif, but no reason is given why the message is not sent.
I should also add, that when sending messages to a group that includes a deactivated user one gets an infinite "sending" gif, but no reason is given why the message is not sent.
@edgarcosta Please file this as a separate issue, and then we'll be able to address it. Thanks!
@gnprice , you know you could have just done that?
@edgarcosta Posting a separate issue in an existing issue thread adds noise that gets in the way of resolving the original issue, and it doesn't help the new issue get fixed. In the future, please post new issues as their own new issue threads.
Please also review the Zulip project's code of conduct, and be mindful of maintaining a positive and respectful atmosphere in this community.

