fix: user public authentication workflow updates (#1207)
* auth integration fixes * auth integration fixes * auth integration fixes * auth integration fixes * dev: update user api to return fallback workspace and improve the structure of the response * dev: fix the issue keyerror and move onboarding logic to serializer method field * dev: use-user-auth hook imlemented for route access validation and build issues resolved effected by user payload * fix: global theme color fix * style: new onboarding ui , fix: use-user-auth hook implemented * fix: command palette, project invite modal and issue detail page mutation type fix * fix: onboarding redirection fix * dev: build isuue resolved * fix: use user auth hook fix * fix: sign in toast alert fix, sign out redirection fix and user theme error fix * fix: user response fix * fix: unAuthorizedStatus logic updated * dev: Implemented SEO in app.tsx * dev: User public auth workflow updates. --------- Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com> Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: anmolsinghbhatia <anmolsinghbhatia@caravel.tech>
This commit is contained in:
parent
77e05a3599
commit
7eae6b4c9e
6 changed files with 44 additions and 14 deletions
|
|
@ -13,6 +13,8 @@ import type { IWorkspace, ICurrentUserResponse } from "types";
|
|||
|
||||
const useUserAuth = (routeAuth: "sign-in" | "onboarding" | "admin" | null = "admin") => {
|
||||
const router = useRouter();
|
||||
const { next_url } = router.query as { next_url: string };
|
||||
|
||||
const [isRouteAccess, setIsRouteAccess] = useState(true);
|
||||
|
||||
const {
|
||||
|
|
@ -48,8 +50,6 @@ const useUserAuth = (routeAuth: "sign-in" | "onboarding" | "admin" | null = "adm
|
|||
};
|
||||
|
||||
const handleUserRouteAuthentication = async () => {
|
||||
console.log("user", user);
|
||||
|
||||
if (user && user.is_active) {
|
||||
if (routeAuth === "sign-in") {
|
||||
if (user.is_onboarded) handleWorkSpaceRedirection();
|
||||
|
|
@ -82,8 +82,10 @@ const useUserAuth = (routeAuth: "sign-in" | "onboarding" | "admin" | null = "adm
|
|||
|
||||
if (!isLoading) {
|
||||
setIsRouteAccess(() => true);
|
||||
if (user) handleUserRouteAuthentication();
|
||||
else {
|
||||
if (user) {
|
||||
if (next_url) router.push(next_url);
|
||||
else handleUserRouteAuthentication();
|
||||
} else {
|
||||
if (routeAuth === "sign-in") {
|
||||
setIsRouteAccess(() => false);
|
||||
return;
|
||||
|
|
@ -93,7 +95,7 @@ const useUserAuth = (routeAuth: "sign-in" | "onboarding" | "admin" | null = "adm
|
|||
}
|
||||
}
|
||||
}
|
||||
}, [user, isLoading, routeAuth, router]);
|
||||
}, [user, isLoading, routeAuth, router, next_url]);
|
||||
|
||||
return {
|
||||
isLoading: isRouteAccess,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue