Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Andcool-Systems committed Feb 8, 2024
1 parent ce9d763 commit d94fe97
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion FileUploaderBot
Submodule FileUploaderBot updated 2 files
+6 −0 README.md
+61 −46 main.py
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Successful execution returns a `200` HTTP code, indicating successful registrati

| errorId | HTTP code | message | Reasons |
| ------- | --------- | -------------- | ------------------ |
| 3 | 400 | Wrong password | Incorrect password |
| 3 | 403 | Wrong password | Incorrect password |
| 4 | 404 | User not found | Username not found |

### Refreshe the token
Expand Down
20 changes: 14 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,17 @@ async def register(request: Request, bot: bool = False):
@limiter.limit(dynamic_limit_provider)
async def login(request: Request, bot: bool = False):
body = await request.json()
if (
"username" not in body or "password" not in body
): # If request body doesn't have username and password field
if ("username" not in body or "password" not in body): # If request body doesn't have username and password field
return JSONResponse(
{
"status": "error",
"message": "No username/password provided",
"errorId": 2,
},
status_code=400,
)

if not body["username"] or not body["password"]:
return JSONResponse(
{
"status": "error",
Expand Down Expand Up @@ -486,8 +494,8 @@ async def login(request: Request, bot: bool = False):
"accessTokenSecret",
algorithm="HS256",
)
if len(user.tokens) > 10: # If user have more than 10 tokens
await db.token.delete_many(where={"user_id": user.id})
#if len(user.tokens) > 10: # If user have more than 10 tokens
# await db.token.delete_many(where={"user_id": user.id})

await db.token.create(
{ # Create token record in db
Expand All @@ -509,7 +517,7 @@ async def login(request: Request, bot: bool = False):
else: # If password doesn't match
return JSONResponse(
{"status": "error", "message": "Wrong password", "errorId": 3},
status_code=400,
status_code=403,
)


Expand Down
2 changes: 1 addition & 1 deletion schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ model Group{
model Invitements{
id Int @id @default(autoincrement())
data String @default("")
group Group @relation(fields: [group_id], references: [id])
group Group @relation(fields: [group_id], references: [id], onDelete: Cascade)
group_id Int @default(0)
}

Expand Down

0 comments on commit d94fe97

Please sign in to comment.