Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

refactor(platform): remove the unused email-update API route (#15686)

Reinier van der Leerac418ff91ec5
diff --git a/autogpt_platform/backend/backend/api/features/user/routes.py b/autogpt_platform/backend/backend/api/features/user/routes.py
index c12771c868..1929d4ca65 100644
--- a/autogpt_platform/backend/backend/api/features/user/routes.py
+++ b/autogpt_platform/backend/backend/api/features/user/routes.py
@@ -20,7 +20,6 @@ from backend.data.user import (
get_or_create_user_with_status,
get_user_notification_preference,
record_signup_consent,
- update_user_email,
update_user_notification_preference,
update_user_timezone,
verify_preference_token,
@@ -30,7 +29,7 @@ from backend.util.settings import Settings
settings = Settings()
logger = logging.getLogger(__name__)
-# Nothing is hoisted onto this router, tags included. Seven of the eight routes
+# Nothing is hoisted onto this router, tags included. Six of the seven routes
# take Security(requires_user); POST /auth/user/preferences/from-email takes
# none — it is reached from an email link and verifies its own signed token —
# so a router-level dependency would silently authenticate it.
@@ -82,20 +81,6 @@ async def get_or_create_user_route(
return user.model_dump()
- "/auth/user/email",
- summary="Update user email",
- tags=["auth"],
- dependencies=[Security(requires_user)],
-)
-async def update_user_email_route(
- user_id: Annotated[str, Security(get_user_id)], email: str = Body(...)
-) -> dict[str, str]:
- await update_user_email(user_id, email)
-
- return {"email": email}
-
-
@router.get(
"/auth/user/timezone",
summary="Get user timezone",
diff --git a/autogpt_platform/backend/backend/api/features/user/routes_test.py b/autogpt_platform/backend/backend/api/features/user/routes_test.py
index 0c17b4b5d6..09b86adc70 100644
--- a/autogpt_platform/backend/backend/api/features/user/routes_test.py
+++ b/autogpt_platform/backend/backend/api/features/user/routes_test.py
@@ -135,29 +135,6 @@ def test_get_or_create_user_route_documents_creation_header() -> None:
}
-def test_update_user_email_route(
- mocker: pytest_mock.MockFixture,
- snapshot: Snapshot,
-) -> None:
- """Test update user email endpoint"""
- mocker.patch(
- "backend.api.features.user.routes.update_user_email",
- return_value=None,
- )
-
- response = client.post("/auth/user/email", json="[email protected]")
-
- assert response.status_code == 200
- response_data = response.json()
- assert response_data["email"] == "[email protected]"
-
- snapshot.snapshot_dir = "snapshots"
- snapshot.assert_match(
- json.dumps(response_data, indent=2, sort_keys=True),
- "auth_email",
- )
-
-
def _consented_user(user_id: str, opted_out_at: datetime | None) -> User:
accepted_at = datetime(2026, 10, 2, 12, 0, tzinfo=timezone.utc)
return User(
@@ -481,19 +458,18 @@ def test_the_frontend_terms_version_is_recognized() -> None:
def test_invalid_json_request() -> None:
"""Test endpoint with invalid JSON"""
response = client.post(
- "/auth/user/email",
+ "/auth/user/timezone",
content="invalid json",
headers={"Content-Type": "application/json"},
)
assert response.status_code == 422
-# The login surface: seven routes authenticate, one deliberately does not.
+# The login surface: six routes authenticate, one deliberately does not.
# Nothing is hoisted onto this router — a router-level dependency would
# silently authenticate the email-link route.
AUTHENTICATED = {
("post", "/api/auth/user"),
- ("post", "/api/auth/user/email"),
("get", "/api/auth/user/timezone"),
("post", "/api/auth/user/timezone"),
("post", "/api/auth/user/consent"),
diff --git a/autogpt_platform/backend/backend/api/paywall_routes_test.py b/autogpt_platform/backend/backend/api/paywall_routes_test.py
index 8421c6bc00..49382ce2cd 100644
--- a/autogpt_platform/backend/backend/api/paywall_routes_test.py
+++ b/autogpt_platform/backend/backend/api/paywall_routes_test.py
@@ -43,7 +43,6 @@ OPEN_WHILE_PAYWALLED = {
"POST /api/api-keys/{key_id}/suspend",
"POST /api/auth/user",
"POST /api/auth/user/consent",
- "POST /api/auth/user/email",
"GET /api/auth/user/preferences",
"POST /api/auth/user/preferences",
"GET /api/auth/user/timezone",
diff --git a/autogpt_platform/backend/backend/data/user.py b/autogpt_platform/backend/backend/data/user.py
index b5209af1f9..17cef61931 100644
--- a/autogpt_platform/backend/backend/data/user.py
+++ b/autogpt_platform/backend/backend/data/user.py
@@ -379,25 +379,6 @@ async def search_users(query: str, limit: int = 20) -> list[tuple[str, str | Non
return [(u.id, u.email) for u in users]
-async def update_user_email(user_id: str, email: str):
- try:
- # Get old email first for cache invalidation
- old_user = await prisma.user.find_unique(where={"id": user_id})
- old_email = old_user.email if old_user else None
-
- await prisma.user.update(where={"id": user_id}, data={"email": email})
-
- # Selectively invalidate only the specific user entries
- get_user_by_id.cache_delete(user_id)
- if old_email:
- get_user_by_email.cache_delete(old_email)
- get_user_by_email.cache_delete(email)
- except Exception as e:
- raise DatabaseError(
- f"Failed to update user email for user {user_id}: {e}"
- ) from e
-
-
async def create_default_user() -> Optional[User]:
user = await prisma.user.find_unique(where={"id": DEFAULT_USER_ID})
if not user:
diff --git a/autogpt_platform/backend/snapshots/auth_email b/autogpt_platform/backend/snapshots/auth_email
deleted file mode 100644
index 178eb291ca..0000000000
--- a/autogpt_platform/backend/snapshots/auth_email
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "email": "[email protected]"
-}
\ No newline at end of file
diff --git a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/settings/__tests__/page.test.tsx b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/settings/__tests__/page.test.tsx
index 7424d58a42..ccbe1e75d8 100644
--- a/autogpt_platform/frontend/src/app/(platform)/profile/(user)/settings/__tests__/page.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/profile/(user)/settings/__tests__/page.test.tsx
@@ -9,7 +9,6 @@ import {
getGetV1GetNotificationPreferencesMockHandler,
getGetV1GetUserTimezoneMockHandler,
getPostV1UpdateNotificationPreferencesMockHandler,
- getPostV1UpdateUserEmailMockHandler,
} from "@/app/api/__generated__/endpoints/auth/auth.msw";
import type { NotificationPreference } from "@/app/api/__generated__/models/notificationPreference";
import type { NotificationPreferenceDTO } from "@/app/api/__generated__/models/notificationPreferenceDTO";
@@ -58,7 +57,6 @@ describe("SettingsPage", () => {
server.use(
getGetV1GetNotificationPreferencesMockHandler(defaultPreferences),
getGetV1GetUserTimezoneMockHandler({ timezone: "Asia/Kolkata" }),
- getPostV1UpdateUserEmailMockHandler({}),
getPostV1UpdateNotificationPreferencesMockHandler(defaultPreferences),
);
@@ -77,7 +75,6 @@ describe("SettingsPage", () => {
server.use(
getGetV1GetNotificationPreferencesMockHandler(defaultPreferences),
getGetV1GetUserTimezoneMockHandler({ timezone: "Asia/Kolkata" }),
- getPostV1UpdateUserEmailMockHandler({}),
getPostV1UpdateNotificationPreferencesMockHandler(async ({ request }) => {
submitted = (await request.json()) as NotificationPreferenceDTO;
return { ...defaultPreferences, ...submitted };
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/account/__tests__/main.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/account/__tests__/main.test.tsx
index b5b52bb006..6d58a5a0db 100644
--- a/autogpt_platform/frontend/src/app/(platform)/settings/account/__tests__/main.test.tsx
+++ b/autogpt_platform/frontend/src/app/(platform)/settings/account/__tests__/main.test.tsx
@@ -5,7 +5,6 @@ import {
getGetV1GetNotificationPreferencesMockHandler,
getGetV1GetUserTimezoneMockHandler,
getPostV1UpdateNotificationPreferencesMockHandler,
- getPostV1UpdateUserEmailMockHandler,
getPostV1UpdateUserTimezoneMockHandler,
} from "@/app/api/__generated__/endpoints/auth/auth.msw";
import type { NotificationPreference } from "@/app/api/__generated__/models/notificationPreference";
@@ -107,7 +106,6 @@ function setupBaseHandlers(
getGetV1GetUserTimezoneMockHandler({
timezone: options.timezone ?? "Asia/Kolkata",
}),
- getPostV1UpdateUserEmailMockHandler({}),
getPostV1UpdateNotificationPreferencesMockHandler(defaultPreferences),
getPostV1UpdateUserTimezoneMockHandler({
timezone: "Europe/London",
@@ -198,7 +196,6 @@ describe("SettingsPreferencesPage", () => {
server.use(
getGetV1GetNotificationPreferencesMockHandler(defaultPreferences),
getGetV1GetUserTimezoneMockHandler({ timezone: "Asia/Kolkata" }),
- getPostV1UpdateUserEmailMockHandler({}),
getPostV1UpdateUserTimezoneMockHandler({ timezone: "Asia/Kolkata" }),
getPostV1UpdateNotificationPreferencesMockHandler(async ({ request }) => {
submitted = (await request.json()) as NotificationPreferenceDTO;
@@ -293,7 +290,6 @@ describe("SettingsPreferencesPage", () => {
server.use(
getGetV1GetNotificationPreferencesMockHandler(defaultPreferences),
getGetV1GetUserTimezoneMockHandler({ timezone: "Asia/Kolkata" }),
- getPostV1UpdateUserEmailMockHandler({}),
getPostV1UpdateUserTimezoneMockHandler({ timezone: "Asia/Kolkata" }),
getPostV1UpdateNotificationPreferencesMockHandler(async ({ request }) => {
submitted = (await request.json()) as NotificationPreferenceDTO;
@@ -353,7 +349,6 @@ describe("SettingsPreferencesPage", () => {
server.use(
getGetV1GetNotificationPreferencesMockHandler(defaultPreferences),
getGetV1GetUserTimezoneMockHandler({ timezone: "Asia/Kolkata" }),
- getPostV1UpdateUserEmailMockHandler({}),
getPostV1UpdateNotificationPreferencesMockHandler(defaultPreferences),
getPostV1UpdateUserTimezoneMockHandler(async ({ request }) => {
const body = (await request.json()) as { timezone: string };
@@ -398,7 +393,6 @@ describe("SettingsPreferencesPage", () => {
server.use(
getGetV1GetNotificationPreferencesMockHandler(defaultPreferences),
getGetV1GetUserTimezoneMockHandler({ timezone: "not-set" }),
- getPostV1UpdateUserEmailMockHandler({}),
getPostV1UpdateNotificationPreferencesMockHandler(defaultPreferences),
getPostV1UpdateUserTimezoneMockHandler(async ({ request }) => {
const body = (await request.json()) as { timezone: string };
diff --git a/autogpt_platform/frontend/src/app/api/openapi.json b/autogpt_platform/frontend/src/app/api/openapi.json
index 35dd794225..4ec7df3f9e 100644
--- a/autogpt_platform/frontend/src/app/api/openapi.json
+++ b/autogpt_platform/frontend/src/app/api/openapi.json
@@ -3111,47 +3111,6 @@
"security": [{ "HTTPBearerJWT": [] }]
}
},
- "/api/auth/user/email": {
- "post": {
- "tags": ["v1", "auth"],
- "summary": "Update user email",
- "operationId": "postV1Update user email",
- "requestBody": {
- "content": {
- "application/json": {
- "schema": { "type": "string", "title": "Email" }
- }
- },
- "required": true
- },
- "responses": {
- "200": {
- "description": "Successful Response",
- "content": {
- "application/json": {
- "schema": {
- "additionalProperties": { "type": "string" },
- "type": "object",
- "title": "Response Postv1Update User Email"
- }
- }
- }
- },
- "401": {
- "$ref": "#/components/responses/HTTP401NotAuthenticatedError"
- },
- "422": {
- "description": "Validation Error",
- "content": {
- "application/json": {
- "schema": { "$ref": "#/components/schemas/HTTPValidationError" }
- }
- }
- }
- },
- "security": [{ "HTTPBearerJWT": [] }]
- }
- },
"/api/auth/user/preferences": {
"get": {
"tags": ["v1", "auth"],
diff --git a/autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts b/autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts
index 6ca2991251..61da0f3552 100644
--- a/autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts
+++ b/autogpt_platform/frontend/src/lib/autogpt-server-api/client.ts
@@ -126,10 +126,6 @@ export default class BackendAPI {
return this._request("POST", "/auth/user", {});
}
- updateUserEmail(email: string): Promise<{ email: string }> {
- return this._request("POST", "/auth/user/email", { email });
- }
-
////////////////////////////////////////
/////////////// CREDITS ////////////////
////////////////////////////////////////