logout fixes with role redirect

This commit is contained in:
kurpfish
2021-08-20 17:33:29 +03:00
parent 8cce68ce06
commit 7891dccb59
14 changed files with 89 additions and 29 deletions

View File

@ -1,11 +1,15 @@
export const withAuthRedirect = actionCall => (link, index) => {
export const withAuthRedirect = actionCall => ({link, index, history, role}) => {
return actionCall(link, index)
.then(res => {
if(res.status && res.status == 401) {
localStorage.clear();
history.push(role === 'ROLE_DEV' ? '/authdev' : '/auth')
}
return res;
})
.catch(err => localStorage.clear())
.catch(err => {
localStorage.clear();
history.push(role === 'ROLE_DEV' ? '/authdev' : '/auth');
})
}