|
1 | 1 | import base64 |
2 | 2 | import json |
3 | 3 | import logging |
4 | | -from typing import Any, Dict, Optional, Tuple, Union |
| 4 | +from typing import Any, Dict, Optional |
5 | 5 | from uuid import UUID |
6 | 6 |
|
7 | 7 | from fastapi import Depends, HTTPException, Request |
|
13 | 13 | from web3login.auth import MoonstreamRegistration, to_checksum_address, verify |
14 | 14 | from web3login.exceptions import MoonstreamVerificationError |
15 | 15 |
|
16 | | -from . import actions, data, models |
| 16 | +from . import actions, data |
17 | 17 | from .db import yield_db_read_only_session |
18 | 18 | from .settings import BOT_INSTALLATION_TOKEN, BOT_INSTALLATION_TOKEN_HEADER |
19 | 19 |
|
@@ -85,11 +85,9 @@ async def get_current_user( |
85 | 85 | if scheme == "moonstream": |
86 | 86 | payload_json = base64.decodebytes(str(token).encode()).decode("utf-8") |
87 | 87 | payload = json.loads(payload_json) |
88 | | - if not isinstance(MoonstreamRegistration, MoonstreamRegistration): |
89 | | - # Mypy hell |
90 | | - raise HTTPException(status_code=500) |
| 88 | + moonstream_schema: Any = MoonstreamRegistration # mypy hell |
91 | 89 | verified = verify( |
92 | | - authorization_payload=payload, schema=MoonstreamRegistration |
| 90 | + authorization_payload=payload, schema=moonstream_schema |
93 | 91 | ) |
94 | 92 | if not verified: |
95 | 93 | logger.info("Moonstream verification error") |
@@ -162,12 +160,10 @@ async def get_current_user_with_groups( |
162 | 160 | if scheme == "moonstream": |
163 | 161 | payload_json = base64.decodebytes(str(token).encode()).decode("utf-8") |
164 | 162 | payload = json.loads(payload_json) |
165 | | - if not isinstance(MoonstreamRegistration, MoonstreamRegistration): |
166 | | - # Mypy hell |
167 | | - raise HTTPException(status_code=500) |
| 163 | + moonstream_schema: Any = MoonstreamRegistration # mypy hell |
168 | 164 | verified = verify( |
169 | | - authorization_payload=payload, schema=MoonstreamRegistration |
170 | | - ) |
| 165 | + authorization_payload=payload, schema=moonstream_schema |
| 166 | + ) |
171 | 167 | if not verified: |
172 | 168 | logger.info("Moonstream authorization verification error") |
173 | 169 | raise MoonstreamVerificationError() |
|
0 commit comments