def login(self, username, password):
     if self.logged_in:
         return "Please logout first."
     else:
         if db.login_check(username, password):
             self.logged_in = True
             self.username = username
             return "Welcome, " + self.username + "."
         else:
             return "Login failed."
Example #2
0
 def login(self):
     if self.logged_in:
         return "Please logout first."
     else:
         username = self.argv[1]
         password = self.argv[2]
         if db.login_check(username, password):
             self.logged_in = True
             self.username = username
             self.bucket = db.get_bucket(username)
             return "Welcome, " + self.username + "."
         else:
             return "Login failed."
Example #3
0
async def login(request):
    # logging of the user
    data = await request.post()
    print("logging")
    try:
        x = db.login_check(
            data["login"],
            hashlib.sha3_256(data["password"].encode()).hexdigest())
        dic = {"token": x}
        print(data['login'])
        print(data['password'])
    except KeyError:
        dic = {"token": "not authorized"}
    return web.json_response(dic)