@@ -85,10 +85,8 @@ async def get_current_user(
8585 if scheme == "moonstream" :
8686 payload_json = base64 .decodebytes (str (token ).encode ()).decode ("utf-8" )
8787 payload = json .loads (payload_json )
88- moonstream_schema : Any = MoonstreamRegistration # mypy hell
89- verified = verify (
90- authorization_payload = payload , schema = moonstream_schema
91- )
88+ moonstream_schema : Any = MoonstreamRegistration # mypy hell
89+ verified = verify (authorization_payload = payload , schema = moonstream_schema )
9290 if not verified :
9391 logger .info ("Moonstream verification error" )
9492 raise MoonstreamVerificationError ()
@@ -106,8 +104,9 @@ async def get_current_user(
106104 if not is_token_active :
107105 raise actions .TokenNotActive ("Access token not active" )
108106 else :
109- logger .error (f"Unaccepted authorization scheme { scheme } " )
110- raise Exception ()
107+ raise HTTPException (
108+ status_code = 401 , detail = "Unaccepted authorization scheme"
109+ )
111110
112111 except actions .TokenNotFound as e :
113112 logger .info (e )
@@ -160,10 +159,8 @@ async def get_current_user_with_groups(
160159 if scheme == "moonstream" :
161160 payload_json = base64 .decodebytes (str (token ).encode ()).decode ("utf-8" )
162161 payload = json .loads (payload_json )
163- moonstream_schema : Any = MoonstreamRegistration # mypy hell
164- verified = verify (
165- authorization_payload = payload , schema = moonstream_schema
166- )
162+ moonstream_schema : Any = MoonstreamRegistration # mypy hell
163+ verified = verify (authorization_payload = payload , schema = moonstream_schema )
167164 if not verified :
168165 logger .info ("Moonstream authorization verification error" )
169166 raise MoonstreamVerificationError ()
@@ -186,8 +183,9 @@ async def get_current_user_with_groups(
186183 if not is_token_active :
187184 raise actions .TokenNotActive ("Access token not active" )
188185 else :
189- logger .error (f"Unaccepted authorization scheme { scheme } " )
190- raise Exception ()
186+ raise HTTPException (
187+ status_code = 401 , detail = "Unaccepted authorization scheme"
188+ )
191189
192190 except actions .TokenNotFound as e :
193191 logger .info (e )
0 commit comments