Fixed authentication redirect upon signin using states

Finally fixed dashboard defaults for new user signups
This commit is contained in:
Muhammad Ibrahim
2025-09-24 07:42:15 +01:00
parent 73761d8927
commit 99aa79a6a4
4 changed files with 31 additions and 23 deletions

View File

@@ -255,6 +255,13 @@ export const AuthProvider = ({ children }) => {
}
}, [token, user, checkAdminUsersExist])
const setAuthState = (authToken, authUser) => {
setToken(authToken)
setUser(authUser)
localStorage.setItem('token', authToken)
localStorage.setItem('user', JSON.stringify(authUser))
}
const value = {
user,
token,
@@ -267,6 +274,7 @@ export const AuthProvider = ({ children }) => {
updateProfile,
changePassword,
refreshPermissions,
setAuthState,
isAuthenticated,
isAdmin,
hasPermission,