예제 #1
0
 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)])
예제 #2
0
USER2 = "test_user2"

USER1 = "test_user1"
print("Adding users")
try:
    addUser(USER1, MAIL1, "pass1")
    addUser(USER2, MAIL2, "pass2")
    addUser(USER3, MAIL3, "pass3")
except HTTPError as error:
    print("FAIL - Users Exist", error)
    exit()
else:
    print("Testing verification")
    print("Trying login without verification")
    try:
        s1 = Session(USER1, "pass1")
        s2 = Session(USER2, "pass2")
        s3 = Session(USER3, "pass3")
    except HTTPError:
        print("OK - login failed")
        print("Attempting verification")
        token1 = input("Enter token for user " + USER1 + " or enter 'MAIL' for email verification: ")
        if token1 == "MAIL":
            v1 = True
        else:
            v1 = verifyUser(USER1, token1)
        token2 = input("Enter token for user " + USER2 + " or enter 'MAIL' for email verification: ")
        if token2 == "MAIL":
            v2 = True
        else:
            v2 = verifyUser(USER2, token2)