Fix: 2FA/passkey page redirect + org Setup context
This commit is contained in:
@@ -49,7 +49,7 @@ async function completeOidcFlow(oidcSessionId: string, token: string): Promise<s
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
const { login, verifyTotp, refreshUser, user, isLoading: authLoading } = useAuth();
|
const { login, verifyTotp, refreshUser, user, isLoading: authLoading, checkOrgAdmin } = useAuth();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
@@ -230,6 +230,7 @@ export default function LoginPage() {
|
|||||||
finishCliFlow(response.token);
|
finishCliFlow(response.token);
|
||||||
} else {
|
} else {
|
||||||
await refreshUser();
|
await refreshUser();
|
||||||
|
await checkOrgAdmin();
|
||||||
navigate('/profile');
|
navigate('/profile');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -347,6 +348,8 @@ export default function LoginPage() {
|
|||||||
|
|
||||||
// Token is stored by completeLogin, refresh user and navigate
|
// Token is stored by completeLogin, refresh user and navigate
|
||||||
await refreshUser();
|
await refreshUser();
|
||||||
|
await checkOrgAdmin();
|
||||||
|
|
||||||
if (oidcSessionId) {
|
if (oidcSessionId) {
|
||||||
const token = tokenManager.getToken();
|
const token = tokenManager.getToken();
|
||||||
if (token) await finishOidcFlow(token);
|
if (token) await finishOidcFlow(token);
|
||||||
@@ -430,6 +433,7 @@ export default function LoginPage() {
|
|||||||
if (token) finishCliFlow(token);
|
if (token) finishCliFlow(token);
|
||||||
} else {
|
} else {
|
||||||
await refreshUser();
|
await refreshUser();
|
||||||
|
await checkOrgAdmin();
|
||||||
navigate('/profile');
|
navigate('/profile');
|
||||||
toast({
|
toast({
|
||||||
title: "Welcome back",
|
title: "Welcome back",
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
import { useState, useEffect } from "react";
|
import { useState, useEffect } from "react";
|
||||||
import { useNavigate, useLocation } from "react-router-dom";
|
import { useNavigate, useLocation } from "react-router-dom";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
import { Building2, Plus, ArrowRight, Loader2, Mail, ChevronDown, ChevronUp } from "lucide-react";
|
import { Building2, Plus, ArrowRight, Loader2, Mail, ChevronDown, ChevronUp } from "lucide-react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
@@ -33,6 +34,7 @@ interface LocationState {
|
|||||||
export default function OrgSetupPage() {
|
export default function OrgSetupPage() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
const queryClient = useQueryClient();
|
||||||
const { refreshUser, checkOrgAdmin, isOrgMember, isLoading } = useAuth();
|
const { refreshUser, checkOrgAdmin, isOrgMember, isLoading } = useAuth();
|
||||||
|
|
||||||
// If the user already belongs to an org (e.g. they bookmarked /org-setup),
|
// If the user already belongs to an org (e.g. they bookmarked /org-setup),
|
||||||
@@ -100,6 +102,7 @@ export default function OrgSetupPage() {
|
|||||||
const done = async () => {
|
const done = async () => {
|
||||||
await refreshUser();
|
await refreshUser();
|
||||||
await checkOrgAdmin();
|
await checkOrgAdmin();
|
||||||
|
queryClient.invalidateQueries({ queryKey: ['organizations'] });
|
||||||
navigate("/profile", { replace: true });
|
navigate("/profile", { replace: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user