mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[root dialog] 3 password attempts for root authentication
This commit is contained in:
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
|
||||
## [0.7.1] 2019-
|
||||
### Improvements
|
||||
- 3 password attempts for root authentication
|
||||
- AUR:
|
||||
- showing a "user-friendly" popup when there are integrity issues with the source-files of a building package
|
||||
### Fixes
|
||||
|
||||
@@ -13,28 +13,41 @@ def is_root():
|
||||
return os.getuid() == 0
|
||||
|
||||
|
||||
def ask_root_password(locale_keys: dict):
|
||||
|
||||
def ask_root_password(i18n: dict):
|
||||
diag = QInputDialog()
|
||||
diag.setStyleSheet("""QLineEdit { border-radius: 5px; font-size: 16px }""")
|
||||
diag.setInputMode(QInputDialog.TextInput)
|
||||
diag.setTextEchoMode(QLineEdit.Password)
|
||||
diag.setWindowIcon(QIcon(resource.get_path('img/lock.png')))
|
||||
diag.setWindowTitle(locale_keys['popup.root.title'])
|
||||
diag.setWindowTitle(i18n['popup.root.title'])
|
||||
diag.setLabelText('')
|
||||
diag.setCancelButtonText(locale_keys['popup.button.cancel'])
|
||||
diag.setCancelButtonText(i18n['popup.button.cancel'])
|
||||
diag.resize(400, 200)
|
||||
|
||||
ok = diag.exec_()
|
||||
for attempt in range(3):
|
||||
|
||||
if ok:
|
||||
if not validate_password(diag.textValue()):
|
||||
show_message(title=locale_keys['popup.root.bad_password.title'],
|
||||
body=locale_keys['popup.root.bad_password.body'],
|
||||
type_=MessageType.ERROR)
|
||||
ok = False
|
||||
ok = diag.exec_()
|
||||
|
||||
return diag.textValue(), ok
|
||||
if ok:
|
||||
if not validate_password(diag.textValue()):
|
||||
|
||||
body = i18n['popup.root.bad_password.body']
|
||||
|
||||
if attempt == 2:
|
||||
body += '. ' + i18n['popup.root.bad_password.last_try']
|
||||
|
||||
show_message(title=i18n['popup.root.bad_password.title'],
|
||||
body=body,
|
||||
type_=MessageType.ERROR)
|
||||
ok = False
|
||||
diag.setTextValue('')
|
||||
|
||||
if ok:
|
||||
return diag.textValue(), ok
|
||||
else:
|
||||
break
|
||||
|
||||
return '', False
|
||||
|
||||
|
||||
def validate_password(password: str) -> bool:
|
||||
|
||||
@@ -38,6 +38,7 @@ manage_window.checkbox.show_details=Show details
|
||||
popup.root.title=Requires your password to continue
|
||||
popup.root.bad_password.title=Error
|
||||
popup.root.bad_password.body=Wrong password
|
||||
popup.root.bad_password.last_try=Attempts finished. Action cancelled.
|
||||
popup.history.title=History
|
||||
popup.history.selected.tooltip=Current version
|
||||
popup.button.yes=Yes
|
||||
|
||||
@@ -39,6 +39,7 @@ manage_window.checkbox.show_details=Mostrar detalles
|
||||
popup.root.title=Requiere tu contraseña para continuar
|
||||
popup.root.bad_password.title=Error
|
||||
popup.root.bad_password.body=Contraseña incorrecta
|
||||
popup.root.bad_password.last_try=Intentos finalizados. Acción cancelada.
|
||||
popup.history.title=Historia
|
||||
popup.history.selected.tooltip=Versión actual
|
||||
popup.button.yes=Sí
|
||||
|
||||
@@ -39,6 +39,7 @@ manage_window.checkbox.show_details=Mostrar detalhes
|
||||
popup.root.title=Requer sua senha para prosseguir
|
||||
popup.root.bad_password.title=Erro
|
||||
popup.root.bad_password.body=Senha incorreta
|
||||
popup.root.bad_password.last_try=Tentativas finalizadas. Ação cancelada.
|
||||
popup.history.title=Histórico
|
||||
popup.history.selected.tooltip=Versão atual
|
||||
popup.button.yes=Sim
|
||||
|
||||
Reference in New Issue
Block a user