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
|
### Added
|
||||||
|
|
||||||
|
- Clarify that the admin page only works for Mastodon and Pleroma instances.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
### Deprecated
|
### 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 some instances being duplicated (due to un-normalized data).
|
||||||
- Fixed mobile instance view erroring for uncrawled instances.
|
- Fixed mobile instance view erroring for uncrawled instances.
|
||||||
|
- Improved error handling in admin login page.
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,9 @@ class LoginScreen extends React.PureComponent<{}, ILoginScreenState> {
|
||||||
<p className={Classes.RUNNING_TEXT}>
|
<p className={Classes.RUNNING_TEXT}>
|
||||||
To manage how fediverse.space interacts with your instance, you must be the instance admin.
|
To manage how fediverse.space interacts with your instance, you must be the instance admin.
|
||||||
</p>
|
</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>
|
<FormContainer error={this.state.error}>{content}</FormContainer>
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
|
@ -172,7 +175,12 @@ class LoginScreen extends React.PureComponent<{}, ILoginScreenState> {
|
||||||
}
|
}
|
||||||
getFromApi(`admin/login/${domain}`)
|
getFromApi(`admin/login/${domain}`)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.setState({ loginTypes: response, isGettingLoginTypes: false });
|
if ("error" in response || "errors" in response) {
|
||||||
|
// Go to catch() below
|
||||||
|
throw new Error();
|
||||||
|
} else {
|
||||||
|
this.setState({ loginTypes: response, isGettingLoginTypes: false });
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
this.setState({ error: true });
|
this.setState({ error: true });
|
||||||
|
@ -183,8 +191,9 @@ class LoginScreen extends React.PureComponent<{}, ILoginScreenState> {
|
||||||
this.setState({ isSendingLoginRequest: true, selectedLoginType: type });
|
this.setState({ isSendingLoginRequest: true, selectedLoginType: type });
|
||||||
postToApi("admin/login", { domain: this.state.loginTypes!.domain, type })
|
postToApi("admin/login", { domain: this.state.loginTypes!.domain, type })
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if ("error" in response) {
|
if ("error" in response || "errors" in response) {
|
||||||
this.setState({ isSendingLoginRequest: false, error: true });
|
// Go to catch() below
|
||||||
|
throw new Error();
|
||||||
} else {
|
} else {
|
||||||
this.setState({ isSendingLoginRequest: false });
|
this.setState({ isSendingLoginRequest: false });
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue