some more login rework
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-04-26 13:18:50 +02:00
parent 772a9e6d2c
commit ae743cde15
3 changed files with 10 additions and 14 deletions

View File

@@ -6,12 +6,11 @@ from netwrapper import NetWrapper
class Server:
def __init__(self, homeDirectory: str = "", sessionTimeout: int = 120, availableServer: bool = True):
def __init__(self, sessionTimeout: int = 120, availableServer: bool = True):
self.isAuthenticated = False
self.homeDirectory = homeDirectory
self.sessionTimeout = sessionTimeout
self.availableServer = availableServer
self.executor = Executor(homeDirectory)
self.executor = Executor("")
def initServer(self):
print("Please enter your private key passphrase")
@@ -20,14 +19,9 @@ class Server:
self.networkInstance = NetWrapper(self.auth.loadUserPublicKeys(), self.auth.loadServerPrivateKey(passphrase),
self.auth)
def login(self, username: str, password: str) -> bool:
def login(self, homeDir: str) -> None:
self.isAuthenticated = True
home_directory = self.auth.login(username, password)
self.executor.baseDir = Executor(home_directory)
if not home_directory:
return False
else:
return True
self.executor.baseDir = Executor(homeDir)
def logout(self) -> None:
self.networkInstance.logout()
@@ -38,6 +32,7 @@ class Server:
def parseCommand(self, command: str) -> None:
if command == "LINOK":
self.login(self.networkInstance.homeDirectory)
self.networkInstance.sendMessage("LINOK".encode('UTF-8'))
elif command == "LINERROR":
self.networkInstance.sendMessage("LINERROR".encode('UTF-8'))
@@ -55,7 +50,7 @@ class Server:
return self.execute(parsedCommand[0], parsedCommand[1], parsedCommand[2])
def execute(self, command: str, firstParam: str = "", secondParam: str = "") -> None:
if self.homeDirectory == "" or self.executor.currentDirectory == "" or self.executor.baseDir == "":
if self.executor.currentDirectory == "" or self.executor.baseDir == "":
raise Exception("Directories must not be empty string. Did the user log in?")
if command == "LOUT":
if secondParam != "" or firstParam != "":