mirror of
https://github.com/stoatchat/for-legacy-web.git
synced 2026-03-07 09:25:27 +00:00
feat: consistent authentication flow
fix: missing suspense on login feat: re-prompt MFA if fail on login
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { Redirect } from "react-router-dom";
|
||||
|
||||
import { Preloader } from "@revoltchat/ui";
|
||||
|
||||
import { clientController } from "../../controllers/client/ClientController";
|
||||
|
||||
interface Props {
|
||||
@@ -10,6 +12,10 @@ interface Props {
|
||||
children: Children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that we are logged in or out and redirect accordingly.
|
||||
* Also prevent render until the client is ready to display.
|
||||
*/
|
||||
export const CheckAuth = observer((props: Props) => {
|
||||
const loggedIn = clientController.isLoggedIn();
|
||||
|
||||
@@ -22,5 +28,14 @@ export const CheckAuth = observer((props: Props) => {
|
||||
return <Redirect to="/" />;
|
||||
}
|
||||
|
||||
// Block render if client is getting ready to work.
|
||||
if (
|
||||
props.auth &&
|
||||
clientController.isLoggedIn() &&
|
||||
!clientController.isReady()
|
||||
) {
|
||||
return <Preloader type="spinner" />;
|
||||
}
|
||||
|
||||
return <>{props.children}</>;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user