login: add check for correct credentials, display proper error

This commit is contained in:
Alexey Manukhin
2024-05-10 01:03:23 -04:00
parent d5a8f4ad03
commit 50dbc6e64b

View File

@@ -188,10 +188,9 @@ r = session.post(
allow_redirects=False, allow_redirects=False,
) )
while True:
if return_url.startswith("/"): if return_url.startswith("/"):
return_url = singlekey_host + return_url return_url = singlekey_host + return_url
while True:
r = session.get(return_url, allow_redirects=False) r = session.get(return_url, allow_redirects=False)
debug(f"{return_url=}, {r} {r.text}") debug(f"{return_url=}, {r} {r.text}")
if r.status_code != 302: if r.status_code != 302:
@@ -205,6 +204,15 @@ debug("--------")
url = urlparse(return_url) url = urlparse(return_url)
query = parse_qs(url.query) query = parse_qs(url.query)
if query.get("ReturnUrl") is not None:
print("Wrong credentials.")
print(
"If you forgot your login/password, you can restore them by opening "
"https://singlekey-id.com/auth/en-us/login in browser"
)
exit(1)
code = query.get("code")[0] code = query.get("code")[0]
state = query.get("state")[0] state = query.get("state")[0]
grant_type = query.get("grant_type")[0] # "authorization_code" grant_type = query.get("grant_type")[0] # "authorization_code"