fix: Not setting the auth state in Application
This commit is contained in:
@@ -11,9 +11,10 @@ import Snackbar from "@material-ui/core/Snackbar";
|
||||
import { withRouter } from "react-router-dom";
|
||||
|
||||
import { IUser } from "../models/user";
|
||||
import { IResponse } from "../models/server";
|
||||
|
||||
interface IProps {
|
||||
login: (username: string, password: string) => Promise<IUser | {}>;
|
||||
login: (username: string, password: string) => Promise<IUser | IResponse>;
|
||||
authenticated: boolean;
|
||||
history: any;
|
||||
|
||||
@@ -35,6 +36,9 @@ const LoginPageWithRouter = withRouter(
|
||||
const username = this.usernameRef.value || "";
|
||||
const password = this.passwordRef.value || "";
|
||||
this.props.login(username, password).then((res: IUser) => {
|
||||
// Stop the loading animation
|
||||
this.props.setLoading(false);
|
||||
|
||||
if (res.showWelcome) {
|
||||
// If the user logs in for the first time, a welcome
|
||||
// screen should be shown
|
||||
@@ -42,7 +46,7 @@ const LoginPageWithRouter = withRouter(
|
||||
} else {
|
||||
this.props.history.push("/dashboard");
|
||||
}
|
||||
}, (err) => {
|
||||
}, (err: IResponse) => {
|
||||
this.props.setLoading(false);
|
||||
this.props.setSnackbar(true, "Failed to log in");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user