improve admin page error handling
This commit is contained in:
parent
cc95d19ee8
commit
a39887856d
|
@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Added
|
||||
|
||||
- Clarify that the admin page only works for Mastodon and Pleroma instances.
|
||||
|
||||
### Changed
|
||||
|
||||
### Deprecated
|
||||
|
@ -19,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- Fixed some instances being duplicated (due to un-normalized data).
|
||||
- Fixed mobile instance view erroring for uncrawled instances.
|
||||
- Improved error handling in admin login page.
|
||||
|
||||
### Security
|
||||
|
||||
|
|
|
@ -76,6 +76,9 @@ class LoginScreen extends React.PureComponent<{}, ILoginScreenState> {
|
|||
<p className={Classes.RUNNING_TEXT}>
|
||||
To manage how fediverse.space interacts with your instance, you must be the instance admin.
|
||||
</p>
|
||||
<p className={Classes.RUNNING_TEXT}>
|
||||
Note that it's currently only possible to administrate Mastodon and Pleroma instances.
|
||||
</p>
|
||||
<FormContainer error={this.state.error}>{content}</FormContainer>
|
||||
</Page>
|
||||
);
|
||||
|
@ -172,7 +175,12 @@ class LoginScreen extends React.PureComponent<{}, ILoginScreenState> {
|
|||
}
|
||||
getFromApi(`admin/login/${domain}`)
|
||||
.then(response => {
|
||||
if ("error" in response || "errors" in response) {
|
||||
// Go to catch() below
|
||||
throw new Error();
|
||||
} else {
|
||||
this.setState({ loginTypes: response, isGettingLoginTypes: false });
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
this.setState({ error: true });
|
||||
|
@ -183,8 +191,9 @@ class LoginScreen extends React.PureComponent<{}, ILoginScreenState> {
|
|||
this.setState({ isSendingLoginRequest: true, selectedLoginType: type });
|
||||
postToApi("admin/login", { domain: this.state.loginTypes!.domain, type })
|
||||
.then(response => {
|
||||
if ("error" in response) {
|
||||
this.setState({ isSendingLoginRequest: false, error: true });
|
||||
if ("error" in response || "errors" in response) {
|
||||
// Go to catch() below
|
||||
throw new Error();
|
||||
} else {
|
||||
this.setState({ isSendingLoginRequest: false });
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue