2024-02-27 00:33:08 +01:00
|
|
|
import json
|
|
|
|
from modules.Tools.logger import debug, warning
|
|
|
|
|
|
|
|
|
|
|
|
class UserCredentials:
|
2024-02-27 01:34:51 +01:00
|
|
|
def __init__(self):
|
2024-02-27 00:33:08 +01:00
|
|
|
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
|