prerelease of list from serrver-db

This commit is contained in:
2026-01-12 15:03:47 +01:00
parent c4b5cac768
commit 7a8b3928a6
10 changed files with 270 additions and 48 deletions
+15 -12
View File
@@ -8,8 +8,7 @@ class Configuration():
This class holds persistent configuration:
- appkey: the app key, alowing traffic with the backend
- last_key_validation_date: last date the appkey was validated, should be no more than a week ago otherwise the app will not run
- username: the user name
- userpwd: the users pwd
- user: the user as a dict
- userlang: the users language
- lastlogin_date: date of last sucessful login
"""
@@ -39,7 +38,6 @@ class Configuration():
def has_valid_app_key(self):
return True
if 'appkey' in self.data:
print("found app key {self.data['appkey']}")
today = datetime.date.today()
last_month = today - datetime.timedelta(days=30)
if self.data['last_key_validation_date'] > last_month:
@@ -53,9 +51,9 @@ class Configuration():
self.save()
def user_is_logged_in(self):
return True
if 'username' in self.data:
print("found user {self.data['username']}")
# return True
if 'user' in self.data:
print(f"found user {self.data['user']['name']}")
today = datetime.date.today()
last_week = today - datetime.timedelta(days=7)
if self.data['lastlogin_date'] > last_week:
@@ -63,9 +61,8 @@ class Configuration():
return True
return False
def store_login(self, user, pwd):
self.data['username'] = user
self.data['userpwd'] = pwd
def store_login(self, user_dict):
self.data['user'] = user_dict
self.data['lastlogin_date'] = datetime.date.today()
self.save()
@@ -75,7 +72,13 @@ class Configuration():
self.data['lastlogin_date'] = today
def logout_user(self):
self.data.pop('username', None)
self.data.pop('userpwd', None)
self.data.pop('user', None)
self.data.pop('lastlogin_date', None)
self.save()
self.save()
def get_userid(self):
result = 0
if 'user' in self.data:
print()
result = self.data['user']['id']
return result