mirror of
https://gitea.augustin64.fr/piair/MsRewards-Reborn.git
synced 2025-06-21 17:53:56 +02:00
updated webUI according to param changes
This commit is contained in:
15
modules/Classes/Config.py
Normal file
15
modules/Classes/Config.py
Normal file
@ -0,0 +1,15 @@
|
||||
import json
|
||||
|
||||
from modules.Classes.UserCredentials import UserCredentials
|
||||
|
||||
|
||||
class Config:
|
||||
def __init__(self, args):
|
||||
self.args = args
|
||||
self.UserCredentials = UserCredentials()
|
||||
|
||||
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
|
||||
configs = json.load(inFile)
|
||||
for i in configs[str(args.config)]["accounts"]:
|
||||
d = configs[str(args.config)]["accounts"][i]
|
||||
self.UserCredentials.add(d["mail"], d["pwd"], d["2fa"])
|
39
modules/Classes/UserCredentials.py
Normal file
39
modules/Classes/UserCredentials.py
Normal file
@ -0,0 +1,39 @@
|
||||
import json
|
||||
from modules.Tools.logger import debug, warning
|
||||
|
||||
|
||||
class UserCredentials:
|
||||
def __init__(self):
|
||||
self.data = {}
|
||||
self.current = 0
|
||||
self.total = 0
|
||||
|
||||
def add(self, username: str, password: str, tfa: str = None):
|
||||
debug(f"adding account with data : Username: {username}, Password: {password}, 2FA: {'None' if tfa == '' else tfa}")
|
||||
self.data[self.total] = {
|
||||
"username": username,
|
||||
"password": password,
|
||||
"2fa": None if tfa == '' else tfa
|
||||
}
|
||||
self.total += 1
|
||||
|
||||
def tfa_enable(self):
|
||||
return self.data[self.current]["2fa"] is not None
|
||||
|
||||
def get_mail(self):
|
||||
return self.data[self.current]["username"]
|
||||
|
||||
def get_password(self):
|
||||
return self.data[self.current]["password"]
|
||||
|
||||
def get_tfa(self):
|
||||
if not self.tfa_enable():
|
||||
warning("Warning: TFA is not enabled. Calling get_tfa is an expected behaviour.")
|
||||
return self.data[self.current]["tfa"]
|
||||
|
||||
def next_account(self):
|
||||
self.current += 1
|
||||
debug(f"New credentials: {self.data[self.current]}")
|
||||
|
||||
def is_valid(self):
|
||||
return self.current < self.total
|
Reference in New Issue
Block a user