Skip to content

Commit

Permalink
fix(store): Make username case insensitive (#9088)
Browse files Browse the repository at this point in the history
Username was case sensitive, made username case insensitive
  • Loading branch information
Swiftyos authored Dec 19, 2024
1 parent 8ca80e0 commit ca91754
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
16 changes: 8 additions & 8 deletions autogpt_platform/backend/backend/server/v2/store/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,22 +578,22 @@ async def get_user_profile(

if not profile:
logger.warning(f"Profile not found for user {user_id}")
await prisma.models.Profile.prisma().create(
new_profile = await prisma.models.Profile.prisma().create(
data=prisma.types.ProfileCreateInput(
userId=user_id,
name="No Profile Data",
username=f"{random.choice(['happy', 'clever', 'swift', 'bright', 'wise'])}-{random.choice(['fox', 'wolf', 'bear', 'eagle', 'owl'])}_{random.randint(1000,9999)}",
username=f"{random.choice(['happy', 'clever', 'swift', 'bright', 'wise'])}-{random.choice(['fox', 'wolf', 'bear', 'eagle', 'owl'])}_{random.randint(1000,9999)}".lower(),
description="No Profile Data",
links=[],
avatarUrl="",
)
)
return backend.server.v2.store.model.ProfileDetails(
name="No Profile Data",
username="No Profile Data",
description="No Profile Data",
links=[],
avatar_url="",
name=new_profile.name,
username=new_profile.username,
description=new_profile.description,
links=new_profile.links,
avatar_url=new_profile.avatarUrl,
)

return backend.server.v2.store.model.ProfileDetails(
Expand Down Expand Up @@ -651,7 +651,7 @@ async def update_or_create_profile(
data={
"userId": user_id,
"name": profile.name,
"username": profile.username,
"username": profile.username.lower(),
"description": profile.description,
"links": profile.links or [],
"avatarUrl": profile.avatar_url,
Expand Down
2 changes: 1 addition & 1 deletion autogpt_platform/backend/backend/server/v2/store/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ async def get_creator(username: str) -> backend.server.v2.store.model.CreatorDet
"""
try:
creator = await backend.server.v2.store.db.get_store_creator_details(
username=username
username=username.lower()
)
return creator
except Exception:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ export default async function Page({
}: {
params: { creator: string; slug: string };
}) {
const creator_lower = params.creator.toLowerCase();
const api = new BackendAPI();
const agent = await api.getStoreAgent(params.creator, params.slug);
const otherAgents = await api.getStoreAgents({ creator: params.creator });
const agent = await api.getStoreAgent(creator_lower, params.slug);
const otherAgents = await api.getStoreAgents({ creator: creator_lower });
const similarAgents = await api.getStoreAgents({
search_query: agent.categories[0],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function generateMetadata({
params: { creator: string };
}): Promise<Metadata> {
const api = new BackendAPI();
const creator = await api.getStoreCreator(params.creator);
const creator = await api.getStoreCreator(params.creator.toLowerCase());

return {
title: `${creator.name} - AutoGPT Store`,
Expand Down

0 comments on commit ca91754

Please sign in to comment.