diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c4a692..d45b4f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/frontend/src/components/screens/LoginScreen.tsx b/frontend/src/components/screens/LoginScreen.tsx index b25ef2f..fe47cb0 100644 --- a/frontend/src/components/screens/LoginScreen.tsx +++ b/frontend/src/components/screens/LoginScreen.tsx @@ -76,6 +76,9 @@ class LoginScreen extends React.PureComponent<{}, ILoginScreenState> {

To manage how fediverse.space interacts with your instance, you must be the instance admin.

+

+ Note that it's currently only possible to administrate Mastodon and Pleroma instances. +

{content} ); @@ -172,7 +175,12 @@ class LoginScreen extends React.PureComponent<{}, ILoginScreenState> { } getFromApi(`admin/login/${domain}`) .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(() => { 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 }); }