このリポジトリは2023-09-09にアーカイブされています。 ファイルの閲覧とクローンは可能ですが、プッシュ、イシューの作成、プルリクエストはできません。
kikikan/backend/resources/js/component/page_change_handler.jsx

22 行
532 B
JavaScript

import axios from "axios";
import { useEffect } from "react";
import { useLocation } from "react-router-dom";
export default function PageChangeHandler() {
const { pathname } = useLocation();
useEffect(() => {
loginAccountCheck();
}, [pathname]);
const loginAccountCheck = () => {
let acc = pathname.split('/')[1];
if(localStorage.getItem('kiki_acc_type') && (acc != localStorage.getItem('kiki_acc_type'))) {
axios.get(`/${acc}/logout`)
location.href= `/${acc}/login`;
}
}
return null;
}