def unauthorize(self): if self.askForConfirmation(strings["confirmUnauthorizeClientText"]): try: self.session.unauthorize() except SecureMessagingException as error: self.showMessageBox.emit(strings["errorText"] + responseTranslations[str(error)]) return storeMessages(self.session.username, None) storeToken(self.session.username, None) storeKey(self.session.username, None, None) self.logout()
def loginThread(): username = self.ui.username.text() password = self.ui.password.text() if username == "" or password == "": self.showMessageBox.emit(strings["missingFieldsErrorText"]) return try: if storage.getToken(username) and storage.getKey(username): token = storage.getToken(username) public, private = storage.getKey(username) newSession = Session(username, password, token, public, private) storage.storeKey(newSession.username, newSession.public, newSession.private) else: token, public, private = Session.requestNewToken(username, password) newSession = Session(username, password, token, public, private) storage.storeToken(newSession.username, token) storage.storeKey(newSession.username, newSession.public, newSession.private) self.loginComplete.emit(newSession) except SecureMessagingException as error: if error.message == HTTPStrings.RESPONSE_UNAUTHORIZED: storage.storeKey(username, None, None) storage.storeToken(username, None) loginThread() return self.showMessageBox.emit(strings["errorText"] + responseTranslations[str(error)])
def renameThread(): newUsername = self.ui.newUsername.text() if newUsername == "": self.showMessageBox.emit(strings["missingFieldsErrorText"]) return try: oldUsername = self.session.username self.session.renameUser(newUsername) for message in sharedData.messages: if message.sender == oldUsername: message.sender = newUsername elif message.receiver == oldUsername: message.receiver = newUsername storeMessages(self.session.username, sharedData.messages) storeToken(self.session.username, self.session.token) storeKey(self.session.username, self.session.public, self.session.private) storeMessages(oldUsername, None) storeToken(oldUsername, None) storeKey(oldUsername, None, None) self.renameCompleted.emit() except SecureMessagingException as error: self.showMessageBox.emit(strings["errorText"] + responseTranslations[str(error)]) return