49 lines
984 B
Python
49 lines
984 B
Python
from os import environ as envar
|
|
|
|
from flask import session
|
|
|
|
VAR_USERNAME = "TD_USERNAME"
|
|
VAR_USERPASS = "TD_USERPASS"
|
|
|
|
|
|
class User:
|
|
"""user informations"""
|
|
|
|
# user name
|
|
name = envar[VAR_USERNAME] if VAR_USERNAME in envar else None
|
|
|
|
# user password
|
|
password = envar[VAR_USERPASS]
|
|
|
|
|
|
class Config:
|
|
"""app configuration"""
|
|
|
|
# app name
|
|
name = "txtdiary"
|
|
|
|
# app description
|
|
description = "Personal diary page"
|
|
|
|
# user
|
|
user = User
|
|
|
|
# where is stored the password info
|
|
_session_login = "logged_in"
|
|
|
|
# data location
|
|
data_dir = "data"
|
|
|
|
@staticmethod
|
|
def is_logged() -> bool:
|
|
"""where the info about connection is stored"""
|
|
return (
|
|
session[Config._session_login]
|
|
if Config._session_login in session
|
|
else False
|
|
)
|
|
|
|
@staticmethod
|
|
def loggin_in() -> None:
|
|
"""where the info about connection is stored"""
|
|
session[Config._session_login] = True
|