Update auth provider
This commit is contained in:
parent
dd4022dcd7
commit
d203a26bde
1 changed files with 9 additions and 9 deletions
|
@ -65,15 +65,6 @@ const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
|
|||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const token = getAuthToken();
|
||||
if (!!token && !userContext) {
|
||||
verifyToken(token);
|
||||
} else {
|
||||
loginWithCredentialsManagementAPI(login);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (tokenAuthOpts.error || tokenVerifyOpts.error) {
|
||||
logout();
|
||||
|
@ -98,6 +89,15 @@ const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
|
|||
}
|
||||
}, [tokenAuthOpts, tokenVerifyOpts]);
|
||||
|
||||
useEffect(() => {
|
||||
const token = getAuthToken();
|
||||
if (!!token && !userContext) {
|
||||
verifyToken(token);
|
||||
} else {
|
||||
loginWithCredentialsManagementAPI(login);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const login = async (email: string, password: string) => {
|
||||
tokenAuth({ variables: { email, password } }).then(result => {
|
||||
if (result && !result.data.tokenCreate.errors.length) {
|
||||
|
|
Loading…
Reference in a new issue