84 lines
1.7 KiB
Python
84 lines
1.7 KiB
Python
import sys
|
|
import argparse
|
|
import os
|
|
import subprocess
|
|
import re
|
|
import hashlib
|
|
import random
|
|
import requests
|
|
import json
|
|
import asyncio
|
|
import threading
|
|
import time
|
|
import string
|
|
import shutil
|
|
import datetime
|
|
|
|
from lib.helpers import *
|
|
from lib.extension import *
|
|
|
|
import streamlit as st
|
|
|
|
ss = st.session_state
|
|
|
|
def more_tokens():
|
|
|
|
tokens = []
|
|
|
|
c = 1
|
|
for t in ss.TOKEN_LIST:
|
|
token = t["token"]
|
|
new_t = {
|
|
"id": c
|
|
}
|
|
new_t.update(t)
|
|
|
|
new_t["name"] = ""
|
|
|
|
try:
|
|
with open(f"user/{token}/settings.json") as f:
|
|
user_json = json.loads(f.read())
|
|
|
|
if "account_name" in user_json.keys():
|
|
new_t["name"] = user_json["account_name"]
|
|
except:
|
|
pass
|
|
|
|
tokens.append(new_t)
|
|
|
|
|
|
c = c + 1
|
|
|
|
def use_token():
|
|
x = 1
|
|
|
|
df = st.dataframe(tokens, on_select=use_token, selection_mode="single-row", use_container_width=True)
|
|
|
|
st.caption("Actions")
|
|
|
|
cols = st.columns([1, 1, 1, 1])
|
|
|
|
with cols[0]:
|
|
#token = st.text_input("Token", help="Provide a valid token here")
|
|
|
|
if st.button("Login", icon=":material/login:", use_container_width=True):
|
|
|
|
|
|
if len(df["selection"]["rows"]) > 0:
|
|
|
|
index = df["selection"]["rows"][0]
|
|
item = tokens[index]
|
|
new_token = item["token"]
|
|
|
|
#st.write(new_token)
|
|
|
|
set_cookie("token_2", new_token)
|
|
page_redirect("/")
|
|
|
|
with cols[1]:
|
|
if st.button("New", icon=":material/add:", use_container_width=True):
|
|
new_token = generate_token()
|
|
mkdir(f"user/{new_token}")
|
|
|
|
page_redirect()
|