feat: align auth api with front convention (#370)

* feat: align auth api with front convention

* fix: email password auth

* fix: proper file naming

* Fix login

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Jérémy M
2023-06-24 07:43:54 +02:00
committed by GitHub
parent c6708b2c1f
commit 31145c5518
23 changed files with 222 additions and 293 deletions
+4 -16
View File
@@ -1,21 +1,9 @@
import { useEffect, useState } from 'react';
import { useRecoilState } from 'recoil';
import { cookieStorage } from '@/utils/cookie-storage';
import { tokenPairState } from '../states/tokenPairState';
export function useIsLogged(): boolean {
const [value, setValue] = useState<string | undefined>(
cookieStorage.getItem('accessToken'),
);
const [tokenPair] = useRecoilState(tokenPairState);
useEffect(() => {
const updateValue = (newValue: string | undefined) => setValue(newValue);
cookieStorage.addEventListener('accessToken', updateValue);
return () => {
cookieStorage.removeEventListener('accessToken', updateValue);
};
}, []);
return !!value;
return !!tokenPair;
}