import json from modules.Tools.logger import debug, warning class UserCredentials: def __init__(self, config_id: int): self.data = {} self.current = 0 self.total = 0 with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile: configs = json.load(inFile) for i in configs[str(config_id)]["accounts"]: d = configs[str(config_id)]["accounts"][i] self.add(d["mail"], d["pwd"], d["2fa"]) debug(f"Initiated UserCredentials.") 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