fixed auth
このコミットが含まれているのは:
コミット
2d675a81b6
ファイル差分が大きすぎるため省略します
差分を読み込み
|
@ -49,12 +49,11 @@ const AdminLogin = () => {
|
|||
let token = {
|
||||
type: 'admin',
|
||||
id: id,
|
||||
from_login: true
|
||||
from_login: true,
|
||||
expires: expires
|
||||
};
|
||||
var dt = new Date(new Date().getTime() + (1*60*1000));
|
||||
console.log(dt);
|
||||
|
||||
setCookie('token', token, {expires: dt, path: '/admin'});
|
||||
|
||||
localStorage.setItem('admin_token', JSON.stringify(token));
|
||||
|
||||
if(location.search == '')
|
||||
window.location.href = "/admin/meeting";
|
||||
|
|
|
@ -16,7 +16,7 @@ export default function AdminSide() {
|
|||
const handleLogout = () => {
|
||||
axios.get('/admin/logout')
|
||||
.then(() => {
|
||||
removeCookie('token', '/admin');
|
||||
localStorage.removeItem('admin_token');
|
||||
window.location.href = '/admin/login';
|
||||
})
|
||||
}
|
||||
|
|
|
@ -50,9 +50,11 @@ const ChildLogin = () => {
|
|||
type: 'c-account',
|
||||
id: id,
|
||||
notice: 0,
|
||||
from_login: true
|
||||
from_login: true,
|
||||
expires: expires
|
||||
};
|
||||
setCookie('token', token, {expires: new Date(expires).toUTCString(), path: '/c-account'});
|
||||
// setCookie('token', token, {expires: new Date(expires).toUTCString(), path: '/c-account'});
|
||||
localStorage.setItem('c-account_token', JSON.stringify(token));
|
||||
localStorage.setItem('child_id', id);
|
||||
|
||||
if(location.search == '')
|
||||
|
|
|
@ -19,7 +19,7 @@ export default function ChildSide() {
|
|||
const handleLogout = () => {
|
||||
axios.get('/c-account/logout')
|
||||
.then(() => {
|
||||
removeCookie('token', '/c-account');
|
||||
localStorage.removeItem('c-account_token');
|
||||
window.location.href = '/c-account/login';
|
||||
})
|
||||
}
|
||||
|
|
|
@ -10,23 +10,24 @@ export default function CheckLoginStatus() {
|
|||
|
||||
const [cookies, setCookie, removeCookie] = useCookies(['user']);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const acc_type = pathname.split('/')[1];
|
||||
|
||||
console.log(cookies.token);
|
||||
let token = cookies.token;
|
||||
|
||||
let token = localStorage.getItem(`${acc_type}_token`);
|
||||
if(!token){
|
||||
navigator(`/${acc_type}/login`);
|
||||
}
|
||||
else{
|
||||
token = JSON.parse(token);
|
||||
if(token.from_login) {
|
||||
setSuccess('ログインに成功しました');
|
||||
token.from_login = false;
|
||||
setCookie('token', token, `/${acc_type}`);
|
||||
localStorage.setItem(`${acc_type}_token`, JSON.stringify(token));
|
||||
}
|
||||
}
|
||||
}, [pathname]);
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -146,7 +146,7 @@ export default function ModalSettingNotify({show, handleClose, meetingId, handle
|
|||
<div className="user-avatar">
|
||||
<img alt="name" className="avatar-img" src={item.child.image} />
|
||||
</div>
|
||||
<p className="user-name">{item.child.first_name} {item.child.last_name}</p>
|
||||
<p className="user-name">{item.child.last_name} {item.child.first_name}</p>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -35,10 +35,12 @@ const ParentLogin = () => {
|
|||
type: 'p-account',
|
||||
id: id,
|
||||
notice: 0,
|
||||
from_login: true
|
||||
from_login: true,
|
||||
expires: expires
|
||||
};
|
||||
|
||||
setCookie('token', token, {expires: new Date(expires).toUTCString(), path: '/p-account'});
|
||||
// setCookie('token', token, {expires: new Date(expires).toUTCString(), path: '/p-account'});
|
||||
localStorage.setItem('p-account_token', JSON.stringify(token));
|
||||
localStorage.setItem('father_id', id);
|
||||
|
||||
if(location.search == '')
|
||||
|
|
|
@ -21,7 +21,7 @@ export default function ParentSide() {
|
|||
const handleLogout = () => {
|
||||
axios.get('/p-account/logout')
|
||||
.then(() => {
|
||||
removeCookie('token', '/p-account');
|
||||
localStorage.removeItem('p-account_token');
|
||||
window.location.href = '/p-account/login';
|
||||
})
|
||||
}
|
||||
|
|
新しいイシューから参照