mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
added session for auth
This commit is contained in:
parent
bb785ea459
commit
27763be864
3 changed files with 33 additions and 0 deletions
18
src/hooks/auth/useSessionCookie.ts
Normal file
18
src/hooks/auth/useSessionCookie.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { useEffect } from 'react';
|
||||
|
||||
import { autorun } from 'mobx';
|
||||
|
||||
import { useAuthStore } from '~/store/auth/useAuthStore';
|
||||
import { setCookie } from '~/utils/dom/cookie';
|
||||
|
||||
export const useSessionCookie = () => {
|
||||
const auth = useAuthStore();
|
||||
|
||||
useEffect(
|
||||
() =>
|
||||
autorun(() => {
|
||||
setCookie('session', auth.token, 30);
|
||||
}),
|
||||
[auth]
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue