reportmonster/src/reportmonster/classes/user.py
2023-07-03 11:24:31 +02:00

43 lines
1.1 KiB
Python

from .database import Database
from ..const import *
from configparser import SectionProxy
from typing import Optional, Union
from datetime import datetime
from MySQLdb.cursors import DictCursor
from bcrypt import hashpw, gensalt
class User:
"""Class describing a User"""
@classmethod
def fromConfig(cls, config: SectionProxy):
"""Create User object from a User section in the Config file
Args:
config (configparser.SectionProxy): User section defining a User
Raises:
KeyError: Raised if section does not contain Password parameter
Returns:
classes.user.User: User object for the user specified in
the config section
"""
return cls(config.name.split()[1], config["Password"])
def __init__(self, username: str, password: str) -> None:
"""Initialize new Vessel object
Args:
name (str): Name of the Vessel
"""
self.username = username
self.password = password
def validatePasword(self, password) -> bool:
return password == self.password