99After initial authentication, the user will need to additionally verify with their callsign.
1010"""
1111
12- from datetime import datetime , timedelta
13- from hashlib import pbkdf2_hmac
12+ from datetime import datetime
1413from os import urandom
15- from typing import Optional
1614from uuid import UUID , uuid4
1715
1816from authlib .integrations .starlette_client import OAuth , OAuthError
1917from starlette .requests import Request
2018from starlette .config import Config
2119from fastapi .responses import RedirectResponse
22- from fastapi import APIRouter , Depends , HTTPException , status
20+ from fastapi import APIRouter , HTTPException , status
2321from pydantic import BaseModel , EmailStr
2422from sqlmodel import select
2523
@@ -204,7 +202,7 @@ async def google_callback(request: Request) -> TokenResponse:
204202 user = get_user_by_google_id (google_id = google_id )
205203 if not user :
206204 # Does the user email already exist?
207- existing_user = get_user_by_email (user )
205+ existing_user = get_user_by_email (email )
208206 if existing_user :
209207 # Link Google Account to existing email
210208 with get_db_session () as session :
@@ -247,9 +245,8 @@ async def register(request: RegisterRequest) -> TokenResponse:
247245 existing_user = get_user_by_email (request .email )
248246 if existing_user :
249247 raise HTTPException (
250-
251248 status_code = status .HTTP_409_CONFLICT ,
252- details = "Email has already been taken." ,
249+ detail = "Email has already been taken." ,
253250 )
254251
255252 # Create all user data
@@ -274,7 +271,7 @@ async def register(request: RegisterRequest) -> TokenResponse:
274271 login = AROUserLogin (
275272 email = user .email ,
276273 password = hashed_password ,
277- password_salt = salt ,
274+ password_salt = salt . hex () ,
278275 hashing_algorithm_name = HASH_ALGORITHM ,
279276 user_data_id = user .id ,
280277 email_verification_token = verification_token ,
@@ -286,7 +283,7 @@ async def register(request: RegisterRequest) -> TokenResponse:
286283 auth_token = create_auth_token (user .id , AROAuthToken .EMAIL_PASSWORD )
287284
288285 return TokenResponse (
289- token = auth_token ,
286+ token = auth_token . token ,
290287 user_id = user .id ,
291288 expires_at = auth_token .expiry ,
292289 )
@@ -312,7 +309,7 @@ async def login(request: LoginRequest) -> TokenResponse:
312309 if not verify_password (request .password , login_record .password_salt , login_record .password ):
313310 raise HTTPException (
314311 status_code = status .HTTP_401_UNAUTHORIZED ,
315- details = "Incorrect email or password." ,
312+ detail = "Incorrect email or password." ,
316313 )
317314
318315 # Get the user data
@@ -327,7 +324,7 @@ async def login(request: LoginRequest) -> TokenResponse:
327324 auth_token = create_auth_token (user .id , AROAuthToken .EMAIL_PASSWORD )
328325
329326 return TokenResponse (
330- token = auth_token ,
327+ token = auth_token . token ,
331328 user_id = user .id ,
332329 expires_at = auth_token .expiry ,
333330 )
@@ -349,10 +346,10 @@ async def logout(token: str) -> dict:
349346 select (AROUserAuthToken ).where (AROUserAuthToken .token == token )
350347 ).first ()
351348
352- if not auth_token () :
349+ if not auth_token :
353350 raise HTTPException (
354351 status_code = status .HTTP_404_NOT_FOUND ,
355- details = "Couldn't find your login credentials. How did you even log in?" ,
352+ detail = "Couldn't find your login credentials. How did you even log in?" ,
356353 )
357354
358355 session .delete (auth_token )
@@ -378,7 +375,7 @@ async def get_current_user(token: str) -> UserResponse:
378375 if not auth_token ():
379376 raise HTTPException (
380377 status_code = status .HTTP_404_NOT_FOUND ,
381- details = "Couldn't find your login credentials. How did you even log in?" ,
378+ detail = "Couldn't find your login credentials. How did you even log in?" ,
382379 )
383380
384381 # Check for expiracy
0 commit comments