Add option to use email address as username

Added option email/no_username to disable username input on form, and
instead use the provided email address as the username. Also added
missing 'packaging' dep from pevious update.
This commit is contained in:
2020-06-29 00:35:51 +01:00
parent 09bbe8fddf
commit 68a459023c
7 changed files with 49 additions and 6 deletions

View File

@@ -106,6 +106,10 @@ for key in ["user_configuration", "user_displayprefs"]:
log.debug(f"Using default {key}")
config["files"][key] = str(data_dir / (key + ".json"))
if "no_username" not in config["email"]:
config["email"]["no_username"] = "false"
log.debug("Set no_username to false")
with open(config["files"]["invites"], "r") as f:
temp_invites = json.load(f)
if "invites" in temp_invites:

View File

@@ -49,7 +49,9 @@ number = 1
special = 0
[email]
; Leave this whole section if you aren't using any email-related features.
; When true, disables username input on invite form and sets the Jellyfin username to the email address
no_username = false
; Leave the rest of this section if you aren't using any email-related features.
use_24h = true
; Date format follows datetime's strftime.
date_format = %d/%m/%y

View File

@@ -68,12 +68,14 @@
<form action="#" method="POST">
<div class="form-group">
<label for="inputEmail">Email</label>
<input type="email" class="form-control" id="inputEmail" name="email" placeholder="Email" value="{{ email }}" required>
<input type="email" class="form-control" id="{% if username %}inputEmail{% else %}inputUsername{% endif %}" name="{% if username %}email{% else %}username{% endif %}" placeholder="Email" value="{{ email }}" required>
</div>
{% if username %}
<div class="form-group">
<label for="inputUsername">Username</label>
<input type="username" class="form-control" id="inputUsername" name="username" placeholder="Username" required>
</div>
{% endif %}
<div class="form-group">
<label for="inputPassword">Password</label>
<input type="password" class="form-control" id="inputPassword" name="password" placeholder="Password" required>
@@ -133,6 +135,9 @@
toggleSpinner();
var send = $("form").serializeObject();
send['code'] = code;
{% if not username %}
send['email'] = send['username'];
{% endif %}
send = JSON.stringify(send);
$.ajax('/newUser', {
data : send,

View File

@@ -1,4 +1,3 @@
import json
from pathlib import Path
from flask import Flask, send_from_directory, render_template
from jellyfin_accounts import config, app, g, css, data_store
@@ -69,6 +68,7 @@ def inviteProxy(path):
validate=config.getboolean("password_validation", "enabled"),
requirements=validator.getCriteria(),
email=email,
username=(not config.getboolean("email", "no_username")),
)
elif "admin.html" not in path and "admin.html" not in path:
return app.send_static_file(path)