#Auth.py
import hashlib
class AuthException(Exception):
def __init__(self, username, user=None):
super().__init__(username, user)
self.username = username
self.user = user
class UsernameAlreadyExists(AuthException):
pass
class PasswordTooShort(AuthException):
pass
class InvalidUsername(AuthException):
pass
class InvalidPassword(AuthException):
pass
class PermissionError(Exception):
pass
class NotLoggedInError(AuthException):
pass
class NotPermittedError(AuthException):
pass
class User:
def __init__(self, username, password):
"""Create a new user object. The password
will be encrypted before storing."""
self.username = username
self.password = self._encrypt_pw(password)
self.is_logged_in = False
def _encrypt_pw(self, password):
"""Encrypt the password with the username and return
|