minor: remove logout handler from singin page (#16237)

This commit is contained in:
Sachin Chaurasiya 2024-05-13 22:32:50 +05:30 committed by GitHub
parent 7451688a21
commit ed7f8cd915
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,7 +14,6 @@
import Icon from '@ant-design/icons/lib/components/Icon'; import Icon from '@ant-design/icons/lib/components/Icon';
import { Button, Col, Divider, Form, Input, Row, Typography } from 'antd'; import { Button, Col, Divider, Form, Input, Row, Typography } from 'antd';
import classNames from 'classnames'; import classNames from 'classnames';
import jwtDecode, { JwtPayload } from 'jwt-decode';
import React, { useEffect, useMemo, useState } from 'react'; import React, { useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
@ -40,13 +39,7 @@ const SignInPage = () => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const history = useHistory(); const history = useHistory();
const { const { authConfig, onLoginHandler, isAuthenticated } = useApplicationStore();
authConfig,
onLoginHandler,
onLogoutHandler,
isAuthenticated,
getOidcToken,
} = useApplicationStore();
const { t } = useTranslation(); const { t } = useTranslation();
@ -61,25 +54,6 @@ const SignInPage = () => {
const { handleLogin, loginError } = useBasicAuth(); const { handleLogin, loginError } = useBasicAuth();
const isTokenExpired = () => {
const token = getOidcToken();
if (token) {
try {
const { exp } = jwtDecode<JwtPayload>(token);
if (exp) {
if (Date.now() < exp * 1000) {
// Token is valid
return false;
}
}
} catch (error) {
// ignore error
}
}
return true;
};
const handleSignIn = () => { const handleSignIn = () => {
onLoginHandler && onLoginHandler(); onLoginHandler && onLoginHandler();
}; };
@ -152,14 +126,6 @@ const SignInPage = () => {
); );
}; };
// If user is neither logged in or nor security is disabled
// invoke logout handler to clean-up any slug storage
useEffect(() => {
if (!isAuthenticated && isTokenExpired()) {
onLogoutHandler();
}
}, []);
useEffect(() => { useEffect(() => {
// If the user is already logged in or if security is disabled // If the user is already logged in or if security is disabled
// redirect the user to the home page. // redirect the user to the home page.