Skip to content

Commit 0e07c14

Browse files
login and magic link require type ObjectID() but currently string (#53)
1 parent 9dba074 commit 0e07c14

File tree

1 file changed

+6
-2
lines changed
  • {{cookiecutter.project_slug}}/backend/app/app/api/api_v1/endpoints

1 file changed

+6
-2
lines changed

{{cookiecutter.project_slug}}/backend/app/app/api/api_v1/endpoints/login.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import Any, Union
22

3+
from bson import ObjectId
4+
35
from fastapi import APIRouter, Body, Depends, HTTPException
46
from fastapi.security import OAuth2PasswordRequestForm
57
from motor.core import AgnosticDatabase
@@ -15,6 +17,8 @@
1517

1618
router = APIRouter()
1719

20+
21+
1822
"""
1923
https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Authentication_Cheat_Sheet.md
2024
Specifies minimum criteria:
@@ -64,7 +68,7 @@ async def validate_magic_link(
6468
"""
6569
claim_in = deps.get_magic_token(token=obj_in.claim)
6670
# Get the user
67-
user = await crud.user.get(db, id=magic_in.sub)
71+
user = await crud.user.get(db, id=ObjectId(magic_in.sub))
6872
# Test the claims
6973
if (
7074
(claim_in.sub == magic_in.sub)
@@ -241,7 +245,7 @@ async def reset_password(
241245
"""
242246
claim_in = deps.get_magic_token(token=claim)
243247
# Get the user
244-
user = await crud.user.get(db, id=magic_in.sub)
248+
user = await crud.user.get(db, id=ObjectId(magic_in.sub))
245249
# Test the claims
246250
if (
247251
(claim_in.sub == magic_in.sub)

0 commit comments

Comments
 (0)