11import logging
22from typing import Annotated , Optional
33
4- import httpx
54from fastapi import APIRouter , Header , HTTPException
65from fastapi .params import Depends
76from httpx import HTTPStatusError
1211from config import Settings , get_settings
1312from db .models import BiocommonsUser , PlatformEnum
1413from db .setup import get_db_session
15- from galaxy .client import GalaxyClient , get_galaxy_client
1614from register .tokens import create_registration_token , verify_registration_token
1715from routers .errors import RegistrationRoute
1816from schemas .biocommons import Auth0UserData , BiocommonsRegisterData
1917from schemas .galaxy import GalaxyRegistrationData
2018from schemas .responses import (
21- FieldError ,
2219 RegistrationErrorResponse ,
2320 RegistrationResponse ,
2421)
@@ -47,7 +44,6 @@ async def get_registration_token(settings: Settings = Depends(get_settings)):
4744def register (
4845 registration_data : GalaxyRegistrationData ,
4946 settings : Annotated [Settings , Depends (get_settings )],
50- galaxy_client : Annotated [GalaxyClient , Depends (get_galaxy_client )],
5147 auth0_client : Annotated [Auth0Client , Depends (get_auth0_client )],
5248 db_session : Annotated [Session , Depends (get_db_session )],
5349 registration_token : Optional [str ] = Header (None ),
@@ -59,19 +55,6 @@ def register(
5955 logger .debug ("Registration token verified." )
6056
6157 user_data = BiocommonsRegisterData .from_galaxy_registration (registration_data )
62- logger .debug ("Checking if username exists in Galaxy" )
63- galaxy_username = user_data .username
64- try :
65- existing = galaxy_client .username_exists (galaxy_username )
66- if existing :
67- username_error = FieldError (field = "username" , message = "Username already exists in Galaxy" )
68- error_response = RegistrationErrorResponse (
69- message = "Username already exists in Galaxy" ,
70- field_errors = [username_error ]
71- )
72- return JSONResponse (status_code = 400 , content = error_response .model_dump (mode = "json" ))
73- except httpx .HTTPError as e :
74- logger .warning (f"Failed to check username in Galaxy: { e } " )
7558
7659 try :
7760 logger .info ("Registering user with Auth0" )
0 commit comments