Handle 2004 login error code;
add regex validation to the username
This commit is contained in:
1 parent
2560bc146f
commit
577a428de2
2 files changed
+9
-2
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
import ctypes
|
import ctypes
|
||||||
import asyncio
|
import asyncio
|
||||||
@@ -474,7 +475,10 @@ class LoginForm:
|
|||||||
self._token_entry.get().strip(),
|
self._token_entry.get().strip(),
|
||||||
)
|
)
|
||||||
# basic input data validation
|
# basic input data validation
|
||||||
if len(login_data.username) < 3:
|
if (
|
||||||
|
3 <= len(login_data.username) <= 25 # 3-25 characters in length
|
||||||
|
and re.match(r'^[a-zA-Z0-9_]+$', login_data.username) # only ascii and underscores
|
||||||
|
):
|
||||||
self.clear(login=True)
|
self.clear(login=True)
|
||||||
continue
|
continue
|
||||||
if len(login_data.password) < 8:
|
if len(login_data.password) < 8:
|
||||||
|
|||||||
@@ -330,9 +330,12 @@ class _AuthState:
|
|||||||
logger.info("1000: CAPTCHA is required")
|
logger.info("1000: CAPTCHA is required")
|
||||||
use_chrome = True
|
use_chrome = True
|
||||||
break
|
break
|
||||||
elif error_code == 3001:
|
elif error_code in (2004, 3001):
|
||||||
logger.info("3001: Login failed due to incorrect username or password")
|
logger.info("3001: Login failed due to incorrect username or password")
|
||||||
gui_print(_("login", "incorrect_login_pass"))
|
gui_print(_("login", "incorrect_login_pass"))
|
||||||
|
if error_code == 2004:
|
||||||
|
# invalid username
|
||||||
|
login_form.clear(login=True)
|
||||||
login_form.clear(password=True)
|
login_form.clear(password=True)
|
||||||
continue
|
continue
|
||||||
elif error_code in (
|
elif error_code in (
|
||||||
|
|||||||
Reference in new issue
Block a user