firts commit
This commit is contained in:
37
src/views/Logout.js
Normal file
37
src/views/Logout.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import { Redirect, useHistory } from "react-router-dom";
|
||||
import { useRecoilState } from "recoil";
|
||||
import { tokenState, ptokenState, questionState } from "../states/Token";
|
||||
import {SelectProject} from '../modules/SelectProject'
|
||||
import { VisitLog } from '../modules/Log';
|
||||
|
||||
const Logout = () => {
|
||||
const history = useHistory();
|
||||
const [token, setToken] = useRecoilState(tokenState);
|
||||
const [pToken, setPtoken] = useRecoilState(ptokenState);
|
||||
const [questionList, setQuestionList] = useRecoilState(questionState);
|
||||
|
||||
useEffect(() => {
|
||||
if(token.token != ''){
|
||||
VisitLog(window.location.href, token.token, '');
|
||||
}
|
||||
|
||||
setToken({
|
||||
status : 0,
|
||||
token : '',
|
||||
name : '',
|
||||
isAdmin : 999,
|
||||
message : '',
|
||||
skey : ''
|
||||
});
|
||||
|
||||
SelectProject('', '', '', 0, '', setPtoken, setQuestionList)
|
||||
},[]);
|
||||
|
||||
if(token.token != '' || pToken.skey != '') return null;
|
||||
|
||||
history.push("/Logout");
|
||||
return <Redirect to={"/Login"} />
|
||||
};
|
||||
|
||||
export default Logout;
|
||||
Reference in New Issue
Block a user