|
|
@ -1,3 +1,5 @@
|
|
|
|
|
|
|
|
from configparser import ConfigParser
|
|
|
|
|
|
|
|
|
|
|
|
import bcrypt
|
|
|
|
import bcrypt
|
|
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
|
|
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Boolean, Numeric
|
|
|
|
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Boolean, Numeric
|
|
|
@ -6,6 +8,11 @@ from sqlalchemy.sql import expression
|
|
|
|
from sqlalchemy.ext.compiler import compiles
|
|
|
|
from sqlalchemy.ext.compiler import compiles
|
|
|
|
from sqlalchemy.types import DateTime as DateTimeType
|
|
|
|
from sqlalchemy.types import DateTime as DateTimeType
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cfg = ConfigParser()
|
|
|
|
|
|
|
|
cfg.read('config.ini')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BCRYPT_LOG_ROUNDS = cfg.get('user', 'BCRYPT_LOG_ROUNDS')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# can be moved to models util?
|
|
|
|
# can be moved to models util?
|
|
|
|
class utcnow(expression.FunctionElement):
|
|
|
|
class utcnow(expression.FunctionElement):
|
|
|
@ -55,7 +62,7 @@ class User(DBMixin, Base):
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, email, password, admin=False):
|
|
|
|
def __init__(self, email, password, admin=False):
|
|
|
|
self.email = email
|
|
|
|
self.email = email
|
|
|
|
self.password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt(13)).decode()
|
|
|
|
self.password = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt(BCRYPT_LOG_ROUNDS)).decode()
|
|
|
|
self.admin = admin
|
|
|
|
self.admin = admin
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|