[FIX] Register crashing when error data is undefined (#2256)

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-07-08 13:52:20 -03:00 committed by Diego Mello
parent 7d2f4afaae
commit 77917f66f0
1 changed files with 4 additions and 2 deletions

View File

@ -145,10 +145,12 @@ class RegisterView extends React.Component {
await loginRequest({ user: email, password });
}
} catch (e) {
if (e.data && e.data.errorType === 'username-invalid') {
if (e.data?.errorType === 'username-invalid') {
return loginRequest({ user: email, password });
}
showErrorAlert(e.data.error, I18n.t('Oops'));
if (e.data?.error) {
showErrorAlert(e.data.error, I18n.t('Oops'));
}
}
this.setState({ saving: false });
}