MCPcopy Create free account
hub / github.com/0010aor/FlashNotes / authentication_token_from_email

Function authentication_token_from_email

backend/tests/utils/user.py:31–50  ·  view source on GitHub ↗

Return a valid token for the user with given email. If the user doesn't exist it is created first.

(
    *, client: TestClient, email: str, db: Session
)

Source from the content-addressed store, hash-verified

29
30
31def authentication_token_from_email(
32 *, client: TestClient, email: str, db: Session
33) -> dict[str, str]:
34 """
35 Return a valid token for the user with given email.
36
37 If the user doesn't exist it is created first.
38 """
39 password = random_lower_string()
40 user = services.get_user_by_email(session=db, email=email)
41 if not user:
42 user_in_create = UserCreate(email=email, password=password)
43 user = services.create_user(session=db, user_create=user_in_create)
44 else:
45 user_in_update = UserUpdate(password=password)
46 if not user.id:
47 raise Exception("User id not set")
48 user = services.update_user(session=db, db_user=user, user_in=user_in_update)
49
50 return user_authentication_headers(client=client, email=email, password=password)

Calls 4

random_lower_stringFunction · 0.90
UserCreateClass · 0.90
UserUpdateClass · 0.90