mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-01-13 17:18:08 -05:00
Compare commits
18 Commits
fix/run-mo
...
hotfix/wai
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d89b84ba2b | ||
|
|
4619b07945 | ||
|
|
d43535e491 | ||
|
|
a35914889a | ||
|
|
7c248f2d6e | ||
|
|
d4a7ce3846 | ||
|
|
605a198c09 | ||
|
|
a3389485a7 | ||
|
|
cd439e912a | ||
|
|
7b32290582 | ||
|
|
e3137382c3 | ||
|
|
65f2c04ef1 | ||
|
|
865abdb9e0 | ||
|
|
b59b200bd6 | ||
|
|
e7fb4cce5a | ||
|
|
85e2aef6ad | ||
|
|
85a8fb598e | ||
|
|
ae20da8aaa |
@@ -6,7 +6,7 @@ import { Button } from "@/components/atoms/Button/Button";
|
||||
import { Text } from "@/components/atoms/Text/Text";
|
||||
import { Card } from "@/components/atoms/Card/Card";
|
||||
import { WaitlistErrorContent } from "@/components/auth/WaitlistErrorContent";
|
||||
import { isWaitlistErrorFromParams } from "@/app/api/auth/utils";
|
||||
import { isWaitlistError } from "@/app/api/auth/utils";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
export default function AuthErrorPage() {
|
||||
@@ -38,12 +38,9 @@ export default function AuthErrorPage() {
|
||||
}
|
||||
|
||||
// Check if this is a waitlist/not allowed error
|
||||
const isWaitlistError = isWaitlistErrorFromParams(
|
||||
errorCode,
|
||||
errorDescription,
|
||||
);
|
||||
const isWaitlistErr = isWaitlistError(errorCode, errorDescription);
|
||||
|
||||
if (isWaitlistError) {
|
||||
if (isWaitlistErr) {
|
||||
return (
|
||||
<div className="flex h-screen items-center justify-center">
|
||||
<Card className="w-full max-w-md p-8">
|
||||
|
||||
@@ -20,6 +20,11 @@ export async function GET(request: Request) {
|
||||
|
||||
const { error } = await supabase.auth.exchangeCodeForSession(code);
|
||||
|
||||
// Keep minimal error logging for OAuth debugging if needed
|
||||
if (error) {
|
||||
console.error("OAuth code exchange failed:", error.message);
|
||||
}
|
||||
|
||||
if (!error) {
|
||||
try {
|
||||
const api = new BackendAPI();
|
||||
|
||||
@@ -59,6 +59,7 @@ export function useSignupPage() {
|
||||
resetCaptcha();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch("/api/auth/provider", {
|
||||
method: "POST",
|
||||
@@ -149,6 +150,7 @@ export function useSignupPage() {
|
||||
setShowNotAllowedModal(true);
|
||||
return;
|
||||
}
|
||||
|
||||
toast({
|
||||
title: result?.error || "Signup failed",
|
||||
variant: "destructive",
|
||||
|
||||
@@ -33,7 +33,7 @@ export async function POST(request: Request) {
|
||||
|
||||
if (error) {
|
||||
// Check for waitlist/allowlist error
|
||||
if (isWaitlistError(error)) {
|
||||
if (isWaitlistError(error?.code, error?.message)) {
|
||||
logWaitlistError("OAuth Provider", error.message);
|
||||
return NextResponse.json({ error: "not_allowed" }, { status: 403 });
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ export async function POST(request: Request) {
|
||||
turnstileToken ?? "",
|
||||
"signup",
|
||||
);
|
||||
|
||||
if (!captchaOk) {
|
||||
return NextResponse.json(
|
||||
{ error: "CAPTCHA verification failed. Please try again." },
|
||||
@@ -49,7 +50,7 @@ export async function POST(request: Request) {
|
||||
|
||||
if (error) {
|
||||
// Check for waitlist/allowlist error
|
||||
if (isWaitlistError(error)) {
|
||||
if (isWaitlistError(error?.code, error?.message)) {
|
||||
logWaitlistError("Signup", error.message);
|
||||
return NextResponse.json({ error: "not_allowed" }, { status: 403 });
|
||||
}
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
/**
|
||||
* Checks if a Supabase auth error is related to the waitlist/allowlist
|
||||
* Checks if an error is related to the waitlist/allowlist
|
||||
*
|
||||
* Can be used with either:
|
||||
* - Error objects from Supabase auth operations: `isWaitlistError(error?.code, error?.message)`
|
||||
* - URL parameters from OAuth callbacks: `isWaitlistError(errorCode, errorDescription)`
|
||||
*
|
||||
* The PostgreSQL trigger raises P0001 with message format:
|
||||
* "The email address "email" is not allowed to register. Please contact support for assistance."
|
||||
*
|
||||
* @param error - The error object from Supabase auth operations
|
||||
* @returns true if this is a waitlist/allowlist error
|
||||
*/
|
||||
export function isWaitlistError(error: any): boolean {
|
||||
if (!error?.message) return false;
|
||||
|
||||
return (
|
||||
error.message.includes("P0001") || // PostgreSQL custom error code
|
||||
error.message.includes("not allowed to register") || // Trigger message
|
||||
error.message.toLowerCase().includes("allowed_users") // Table reference
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if OAuth callback URL parameters indicate a waitlist error
|
||||
*
|
||||
* This is for the auth-code-error page which receives errors via URL hash params
|
||||
* from Supabase OAuth redirects
|
||||
*
|
||||
* @param errorCode - The error_code parameter from the URL
|
||||
* @param errorDescription - The error_description parameter from the URL
|
||||
* @param code - Error code (e.g., "P0001", "unexpected_failure") or null
|
||||
* @param message - Error message/description or null
|
||||
* @returns true if this appears to be a waitlist/allowlist error
|
||||
*/
|
||||
export function isWaitlistErrorFromParams(
|
||||
errorCode?: string | null,
|
||||
errorDescription?: string | null,
|
||||
export function isWaitlistError(
|
||||
code?: string | null,
|
||||
message?: string | null,
|
||||
): boolean {
|
||||
if (!errorDescription) return false;
|
||||
// Check for explicit PostgreSQL trigger error code
|
||||
if (code === "P0001") return true;
|
||||
|
||||
const description = errorDescription.toLowerCase();
|
||||
if (!message) return false;
|
||||
|
||||
const lowerMessage = message.toLowerCase();
|
||||
|
||||
// Check for the generic database error that occurs during waitlist check
|
||||
// This happens when Supabase wraps the PostgreSQL trigger error
|
||||
if (
|
||||
code === "unexpected_failure" &&
|
||||
message === "Database error saving new user"
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for various waitlist-related patterns in the message
|
||||
return (
|
||||
description.includes("p0001") || // PostgreSQL error code might be in description
|
||||
description.includes("not allowed") ||
|
||||
description.includes("waitlist") ||
|
||||
description.includes("allowlist") ||
|
||||
description.includes("allowed_users")
|
||||
lowerMessage.includes("p0001") || // PostgreSQL error code in message
|
||||
lowerMessage.includes("not allowed") || // Common waitlist message
|
||||
lowerMessage.includes("waitlist") || // Explicit waitlist mention
|
||||
lowerMessage.includes("allowlist") || // Explicit allowlist mention
|
||||
lowerMessage.includes("allowed_users") || // Database table reference
|
||||
lowerMessage.includes("not allowed to register") // Full trigger message
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user