Logout user on failure when login via external source (#3405)
This commit is contained in:
parent
5beabd431d
commit
fc43969114
4 changed files with 26452 additions and 27 deletions
26466
package-lock.json
generated
26466
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -34,7 +34,7 @@
|
|||
"@material-ui/styles": "^4.11.4",
|
||||
"@reach/auto-id": "^0.16.0",
|
||||
"@saleor/macaw-ui": "^0.8.0-pre.52",
|
||||
"@saleor/sdk": "^0.4.4",
|
||||
"@saleor/sdk": "^0.4.5",
|
||||
"@sentry/react": "^6.0.0",
|
||||
"@types/faker": "^5.1.6",
|
||||
"@uiw/react-color-hue": "0.0.34",
|
||||
|
|
|
@ -5,6 +5,9 @@ import { makeStyles, useTheme } from "@saleor/macaw-ui";
|
|||
import React from "react";
|
||||
import SVG from "react-inlinesvg";
|
||||
|
||||
import { useUser } from "..";
|
||||
import LoginLoading from "./LoginLoading";
|
||||
|
||||
const useStyles = makeStyles(
|
||||
theme => ({
|
||||
logo: {
|
||||
|
@ -72,10 +75,17 @@ const useStyles = makeStyles(
|
|||
|
||||
const Layout: React.FC = props => {
|
||||
const { children } = props;
|
||||
const { errors } = useUser();
|
||||
|
||||
const classes = useStyles(props);
|
||||
const { themeType } = useTheme();
|
||||
|
||||
// show fullscreen loading when there is externalLoginError - we will redirect and
|
||||
// logout user in meantime
|
||||
if (errors.some(item => item === "externalLoginError")) {
|
||||
return <LoginLoading />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<div className={classes.mainPanel}>
|
||||
|
|
|
@ -189,6 +189,7 @@ export function useAuthProvider({
|
|||
}
|
||||
} else {
|
||||
setErrors(["externalLoginError"]);
|
||||
await handleLogout();
|
||||
}
|
||||
|
||||
await logoutNonStaffUser(result.data.externalObtainAccessTokens);
|
||||
|
|
Loading…
Reference in a new issue