Beispiel #1
0
    def delete(_username, _password, user):
        """ Delete with a check of the password in Database """
        db = Database()
        result = db.select_one('''SELECT idUser, password FROM user WHERE username LIKE ?''', (_username, ))

        if result is not None:
            if result[1] != "":
                if bcrypt.checkpw(_password.encode('utf-8'), result[1].encode('utf-8')):
                    for hero in user.heroes:
                        hero.delete()
                    db.delete("DELETE FROM user WHERE username = ?", (_username,))
                else:
                    return "Error : Invalid Password"
            else:
                return "Error : Invalid Username"
        else:
            return "Error : no user found"
Beispiel #2
0
 def delete(self):
     """ Delete table tuple corresponding to current instance  """
     db = Database()
     db.delete("DELETE FROM hero WHERE nameOfTheHero = ?", (self.name,))