replaced attribute with get call

This commit is contained in:
b3yond 2019-01-11 13:23:37 +01:00
parent 2ce27fc52f
commit 76b3b574f0

9
db.py
View file

@ -14,7 +14,6 @@ class DB(object):
self.conn = sqlite3.connect(dbfile) self.conn = sqlite3.connect(dbfile)
self.cur = self.conn.cursor() self.cur = self.conn.cursor()
self.create() self.create()
self.secret = self.get_secret()
def execute(self, *args, **kwargs): def execute(self, *args, **kwargs):
return self.cur.execute(*args, **kwargs) return self.cur.execute(*args, **kwargs)
@ -189,7 +188,7 @@ class DB(object):
'passhash': scrypt_mcf( 'passhash': scrypt_mcf(
password.encode('utf-8') password.encode('utf-8')
).decode('ascii') ).decode('ascii')
}, self.secret).decode('ascii') }, self.get_secret()).decode('ascii')
def mail_subscription_token(self, email, city): def mail_subscription_token(self, email, city):
""" """
@ -203,17 +202,17 @@ class DB(object):
token = jwt.encode({ token = jwt.encode({
'email': email, 'email': email,
'city': city 'city': city
}, self.secret).decode('ascii') }, self.get_secret()).decode('ascii')
return token return token
def confirm_subscription(self, token): def confirm_subscription(self, token):
json = jwt.decode(token, self.secret) json = jwt.decode(token, self.get_secret())
return json['email'], json['city'] return json['email'], json['city']
def confirm(self, token, city): def confirm(self, token, city):
from user import User from user import User
try: try:
json = jwt.decode(token, self.secret) json = jwt.decode(token, self.get_secret())
except jwt.DecodeError: except jwt.DecodeError:
return None # invalid token return None # invalid token
if 'passhash' in json.keys(): if 'passhash' in json.keys():