Update authentication flow and remove unused verification components

Refactors authentication context and login page, removing manual verification UI and ensuring proper profile creation via auth state changes. Updates Supabase auth linking and unlinking types.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 9203795e-937a-4306-b81d-b4d5c78c240e
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Event-Id: ec4482a8-b3eb-4d1e-8edb-34a8f6b04f0b
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7c94b7a0-29c7-4f2e-94ef-44b2153872b7/9203795e-937a-4306-b81d-b4d5c78c240e/fhRML7y
Replit-Helium-Checkpoint-Created: true
This commit is contained in:
sirpiglr 2025-12-06 03:30:01 +00:00
parent 2ae7dc4b69
commit c2b45166b8
3 changed files with 24 additions and 69 deletions

View file

@ -60,6 +60,10 @@ externalPort = 3000
localPort = 40437
externalPort = 3001
[[ports]]
localPort = 40897
externalPort = 3002
[deployment]
deploymentTarget = "autoscale"
run = ["node", "dist/server/production.mjs"]

View file

@ -533,8 +533,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
// ignore
}
// Return user data for caller to use (e.g., Login.tsx)
return { user: data?.user ?? null };
// Navigation is handled by AuthContext's useEffect watching user state
} catch (error: any) {
console.error("SignIn error details:", error);
@ -662,7 +661,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
}
}
return { emailSent, verificationUrl } as const;
// Navigation is handled by AuthContext's useEffect watching user state
} catch (error: any) {
aethexToast.error({
title: "Sign up failed",
@ -786,7 +785,7 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
console.log("[Discord Link] Redirecting to Discord OAuth...");
const u = new URL("/api/discord/oauth/start", apiBase);
const u = new URL("/api/discord/oauth/start", API_BASE);
u.searchParams.set(
"state",
encodeURIComponent(
@ -812,10 +811,10 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
// For other providers (GitHub, Google), use Supabase's built-in linking
try {
const { data, error } = (await supabase.auth.linkIdentity({
const { data, error } = await (supabase.auth.linkIdentity as any)({
provider,
redirectTo: `${window.location.origin}/dashboard?tab=connections`,
})) as any;
});
if (error) throw error;
const linkUrl = data?.url;
if (linkUrl) {
@ -875,10 +874,10 @@ export const AuthProvider: React.FC<{ children: React.ReactNode }> = ({
return;
}
try {
const { error } = (await supabase.auth.unlinkIdentity({
const { error } = await (supabase.auth.unlinkIdentity as any)({
identity_id: identity.identity_id,
provider,
})) as any;
});
if (error) throw error;
await refreshAuthState();
aethexToast.success({

View file

@ -63,9 +63,6 @@ export default function Login() {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [fullName, setFullName] = useState("");
const [manualVerificationLink, setManualVerificationLink] = useState<
string | null
>(null);
const [showReset, setShowReset] = useState(false);
const [resetEmail, setResetEmail] = useState("");
const [errorFromUrl, setErrorFromUrl] = useState<string | null>(null);
@ -169,33 +166,19 @@ export default function Login() {
try {
if (isSignUp) {
const result = await signUp(email, password, {
data: {
full_name: fullName,
},
await signUp(email, password, {
full_name: fullName,
});
toastInfo({
title: "Account created",
description: "Redirecting to onboarding...",
});
if (result?.user) {
toastInfo({
title: "Account created",
description:
result?.identities?.length === 0
? "Please verify your email to log in"
: "Redirecting to onboarding...",
});
await aethexUserService.ensureUserProfile(result.user);
navigate("/onboarding", { replace: true });
}
} else {
// Sign in with email/password
const result = await signIn(email, password);
if (result?.user) {
// Don't navigate immediately - let Auth context update and the useEffect below handle redirect
// This ensures profile data is fetched and profileComplete is properly calculated
toastInfo({
title: "Signing you in",
description: "Redirecting...",
});
}
await signIn(email, password);
toastInfo({
title: "Signing you in",
description: "Redirecting...",
});
}
} catch (error: any) {
console.error("Auth error:", error);
@ -211,7 +194,7 @@ export default function Login() {
}
};
const handleSocialLogin = async (provider: string) => {
const handleSocialLogin = async (provider: "github" | "google" | "discord") => {
try {
await signInWithOAuth(provider);
} catch (error) {
@ -289,9 +272,8 @@ export default function Login() {
return (
<>
<SEO
title="Sign In to AeThex"
pageTitle="Sign In to AeThex"
description="Create or access your AeThex creator account"
image={window.location.href ? window.location.href : (undefined as any)}
/>
<Layout>
<div className="min-h-screen bg-aethex-gradient py-12 flex items-center justify-center">
@ -354,36 +336,6 @@ export default function Login() {
<AlertDescription>{errorFromUrl}</AlertDescription>
</Alert>
) : null}
{manualVerificationLink ? (
<Alert className="border-aethex-400/30 bg-aethex-500/10 text-foreground">
<Info className="h-4 w-4 text-aethex-300" />
<AlertTitle>Manual verification required</AlertTitle>
<AlertDescription>
<p>
We couldn't send the verification email automatically.
Use the link below to confirm your account:
</p>
<p className="mt-2 break-all rounded bg-background/60 px-3 py-2 font-mono text-xs text-foreground/90">
{manualVerificationLink}
</p>
<Button
type="button"
size="sm"
variant="outline"
className="mt-3 border-aethex-400/40"
onClick={() =>
window.open(
manualVerificationLink,
"_blank",
"noopener",
)
}
>
Open verification link
</Button>
</AlertDescription>
</Alert>
) : null}
{/* Social Login Buttons */}
<div className="space-y-3">
<div className="space-y-2">