def create_employee(cls) -> (bool, str):

        fields = ("username", "first_name", "last_name", "password")
        username, first_name, last_name, password = list(
            input(f"{field} :") for field in fields)

        if not User.exists_with_username(username):
            User.save(username=username,
                      password=password,
                      first_name=first_name,
                      last_name=last_name,
                      role=EnumRole.EMPLOYEE)
            return True, ""
        else:
            return False, f"This username: {username} already exists"
Exemplo n.º 2
0
 def save(cls, username: str = None, role: str = None) -> bool:
     if User.exists_with_username(username):
         if not cls.exists_with_username(username):
             cls.__sessions[username] = dict(role=role)
             return True
     return False