Skip to content

Commit

Permalink
login and magic link require type ObjectID() but currently string (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
scattered-development authored Sep 6, 2024
1 parent 9dba074 commit 0e07c14
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import Any, Union

from bson import ObjectId

from fastapi import APIRouter, Body, Depends, HTTPException
from fastapi.security import OAuth2PasswordRequestForm
from motor.core import AgnosticDatabase
Expand All @@ -15,6 +17,8 @@

router = APIRouter()



"""
https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Authentication_Cheat_Sheet.md
Specifies minimum criteria:
Expand Down Expand Up @@ -64,7 +68,7 @@ async def validate_magic_link(
"""
claim_in = deps.get_magic_token(token=obj_in.claim)
# Get the user
user = await crud.user.get(db, id=magic_in.sub)
user = await crud.user.get(db, id=ObjectId(magic_in.sub))
# Test the claims
if (
(claim_in.sub == magic_in.sub)
Expand Down Expand Up @@ -241,7 +245,7 @@ async def reset_password(
"""
claim_in = deps.get_magic_token(token=claim)
# Get the user
user = await crud.user.get(db, id=magic_in.sub)
user = await crud.user.get(db, id=ObjectId(magic_in.sub))
# Test the claims
if (
(claim_in.sub == magic_in.sub)
Expand Down

0 comments on commit 0e07c14

Please sign in to comment.