Add ability to have simple passwords
This commit is contained in:
parent
bb77e85ded
commit
bbf348c1dc
@ -5,7 +5,7 @@ import string
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
from wonderwords import RandomWord
|
from wonderwords import RandomWord
|
||||||
|
|
||||||
from global_variables import JELLYFIN_URL, JELLYFIN_HEADERS, ACCOUNT_TIME
|
from global_variables import JELLYFIN_URL, JELLYFIN_HEADERS, ACCOUNT_TIME, SIMPLE_PASSWORDS
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Create a new Jellyfin account for the user and return the username and password
|
Create a new Jellyfin account for the user and return the username and password
|
||||||
@ -14,7 +14,10 @@ Create a new Jellyfin account for the user and return the username and password
|
|||||||
|
|
||||||
def create_jellyfin_account(user_id):
|
def create_jellyfin_account(user_id):
|
||||||
username = RandomWord().word(word_min_length=5, word_max_length=5)
|
username = RandomWord().word(word_min_length=5, word_max_length=5)
|
||||||
password = "".join(random.choices(string.ascii_lowercase + string.digits, k=15))
|
if SIMPLE_PASSWORDS:
|
||||||
|
password = RandomWord().word(word_min_length=5, word_max_length=10)
|
||||||
|
else:
|
||||||
|
password = "".join(random.choices(string.ascii_lowercase + string.digits, k=15))
|
||||||
|
|
||||||
deletion_time = datetime.datetime.now() + datetime.timedelta(hours=ACCOUNT_TIME)
|
deletion_time = datetime.datetime.now() + datetime.timedelta(hours=ACCOUNT_TIME)
|
||||||
# Create the new Jellyfin account
|
# Create the new Jellyfin account
|
||||||
|
@ -38,7 +38,8 @@ except FileNotFoundError:
|
|||||||
config["JELLYFIN_ACCOUNTS"] = {
|
config["JELLYFIN_ACCOUNTS"] = {
|
||||||
"JELLYFIN_URL": "",
|
"JELLYFIN_URL": "",
|
||||||
"JELLYFIN_API_KEY": "",
|
"JELLYFIN_API_KEY": "",
|
||||||
"ACCOUNT_TIME": ""
|
"ACCOUNT_TIME": "",
|
||||||
|
"SIMPLE_PASSWORDS": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
with open("config.ini", "w") as configfile:
|
with open("config.ini", "w") as configfile:
|
||||||
@ -74,3 +75,8 @@ JELLYFIN_HEADERS = {
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"X-Emby-Token": JELLYFIN_API_KEY,
|
"X-Emby-Token": JELLYFIN_API_KEY,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config["JELLYFIN_ACCOUNTS"]["SIMPLE_PASSWORDS"].lower() in YES_VALUES:
|
||||||
|
SIMPLE_PASSWORDS = True
|
||||||
|
else:
|
||||||
|
SIMPLE_PASSWORDS = False
|
@ -96,6 +96,14 @@ def validate_config(file_contents):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
LOG.error("Invalid value passed to ACCOUNT_TIME. Pass a valid integer value (e.g. 24)")
|
LOG.error("Invalid value passed to ACCOUNT_TIME. Pass a valid integer value (e.g. 24)")
|
||||||
errors += 1
|
errors += 1
|
||||||
|
# Validate SIMPLE_PASSWORDS
|
||||||
|
if not config["JELLYFIN_ACCOUNTS"]["SIMPLE_PASSWORDS"]:
|
||||||
|
LOG.error("Empty SIMPLE_PASSWORDS passed. Pass a true/false value.")
|
||||||
|
errors += 1
|
||||||
|
else:
|
||||||
|
if (config["JELLYFIN_ACCOUNTS"]["SIMPLE_PASSWORDS"].lower() not in YES_VALUES + NO_VALUES):
|
||||||
|
LOG.error("Invalid value passed to SIMPLE_PASSWORDS. Pass a true/false value.")
|
||||||
|
errors += 1
|
||||||
|
|
||||||
# Make sure connection to Jellyfin API can be established
|
# Make sure connection to Jellyfin API can be established
|
||||||
jellyfin_headers = {
|
jellyfin_headers = {
|
||||||
@ -161,5 +169,6 @@ def create_config():
|
|||||||
config["JELLYFIN_ACCOUNTS"] = {
|
config["JELLYFIN_ACCOUNTS"] = {
|
||||||
"JELLYFIN_URL": "",
|
"JELLYFIN_URL": "",
|
||||||
"JELLYFIN_API_KEY": "",
|
"JELLYFIN_API_KEY": "",
|
||||||
"ACCOUNT_TIME": ""
|
"ACCOUNT_TIME": "",
|
||||||
|
"SIMPLE_PASSWORDS": "",
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user