reportmonster/src/reportmonster/classes/user.py

45 lines
1.1 KiB
Python

from classes.database import Database
from configparser import SectionProxy
from typing import Optional, Union
from datetime import datetime
from MySQLdb.cursors import DictCursor
from bcrypt import hashpw, gensalt
from const import *
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