fix auth misprint
This commit is contained in:
parent
a074c86086
commit
40fd420b67
|
|
@ -52,12 +52,12 @@ async def s_api_v1_auth_twa(request):
|
|||
wallet_info.account = Account.from_dict(auth_data['ton_proof']['account'])
|
||||
wallet_info.ton_proof = TonProof.from_dict({'proof': auth_data['ton_proof']['ton_proof']})
|
||||
connection_payload = auth_data['ton_proof']['ton_proof']['payload']
|
||||
known_payload = (await request.ctx.db_session.execute(select(KnownKey).where(KnownKey.seed == connection_payload))).scalars().first()
|
||||
known_payload = (request.ctx.db_session.execute(select(KnownKey).where(KnownKey.seed == connection_payload))).scalars().first()
|
||||
assert known_payload, "Unknown payload"
|
||||
assert known_payload.meta['I_user_id'] == known_user.id, "Invalid user_id"
|
||||
assert wallet_info.check_proof(connection_payload), "Invalid proof"
|
||||
|
||||
for known_connection in (await request.ctx.db_session.execute(select(WalletConnection).where(
|
||||
for known_connection in (request.ctx.db_session.execute(select(WalletConnection).where(
|
||||
and_(
|
||||
WalletConnection.user_id == known_user.id,
|
||||
WalletConnection.network == 'ton'
|
||||
|
|
@ -65,7 +65,7 @@ async def s_api_v1_auth_twa(request):
|
|||
))).scalars().all():
|
||||
known_connection.invalidated = True
|
||||
|
||||
for other_connection in (await request.ctx.db_session.execute(select(WalletConnection).where(
|
||||
for other_connection in (request.ctx.db_session.execute(select(WalletConnection).where(
|
||||
WalletConnection.wallet_address == Address(wallet_info.account.address).to_string(1, 1, 1)
|
||||
))).scalars().all():
|
||||
other_connection.invalidated = True
|
||||
|
|
@ -86,7 +86,7 @@ async def s_api_v1_auth_twa(request):
|
|||
without_pk=False
|
||||
)
|
||||
request.ctx.db_session.add(new_connection)
|
||||
await request.ctx.db_session.commit()
|
||||
request.ctx.db_session.commit()
|
||||
except BaseException as e:
|
||||
make_log("auth", f"Invalid ton_proof: {e}", level="warning")
|
||||
return response.json({"error": "Invalid ton_proof"}, status=400)
|
||||
|
|
|
|||
Loading…
Reference in New Issue