mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Properly invalidate exceptions
The simple authenticator now properly invalidates its credentials. Also, the invalidation functions have been given better names and documentation.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
from typing import Optional, Tuple
|
||||
|
||||
from ..authenticator import Authenticator, AuthSection
|
||||
from ..authenticator import Authenticator, AuthException, AuthSection
|
||||
from ..conductor import TerminalConductor
|
||||
from ..config import Config
|
||||
from ..utils import agetpass, ainput
|
||||
@ -42,7 +42,26 @@ class SimpleAuthenticator(Authenticator):
|
||||
|
||||
if self.password is None:
|
||||
self.password = await agetpass("Password: ")
|
||||
else:
|
||||
print("Password: *******")
|
||||
|
||||
return self.username, self.password
|
||||
|
||||
def invalidate_credentials(self) -> None:
|
||||
if self.username_fixed and self.password_fixed:
|
||||
raise AuthException("Configured credentials are invalid")
|
||||
|
||||
if not self.username_fixed:
|
||||
self.username = None
|
||||
if not self.password_fixed:
|
||||
self.password = None
|
||||
|
||||
def invalidate_username(self) -> None:
|
||||
if self.username_fixed:
|
||||
raise AuthException("Configured username is invalid")
|
||||
else:
|
||||
self.username = None
|
||||
|
||||
def invalidate_password(self) -> None:
|
||||
if self.password_fixed:
|
||||
raise AuthException("Configured password is invalid")
|
||||
else:
|
||||
self.password = None
|
||||
|
Reference in New Issue
Block a user