Logout user on failure when login via external source (#3405)

This commit is contained in:
Krzysztof Żuraw 2023-03-30 11:14:53 +02:00 committed by GitHub
parent 5beabd431d
commit fc43969114
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26452 additions and 27 deletions

26466
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -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",

View file

@ -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}>

View file

@ -189,6 +189,7 @@ export function useAuthProvider({
}
} else {
setErrors(["externalLoginError"]);
await handleLogout();
}
await logoutNonStaffUser(result.data.externalObtainAccessTokens);