mirror of
https://github.com/hrfee/jellyfin-accounts.git
synced 2024-12-22 09:00:14 +00:00
pw requirements now loaded with jinja over js
Originally i loaded the requirements through calling the web api in javascript, but decided to switch it to jinja as i only recently found out its capable of stuff more complicated than replacing strings.
This commit is contained in:
parent
8497cd4927
commit
331dbc3d28
4
.gitignore
vendored
4
.gitignore
vendored
@ -8,3 +8,7 @@ data/node_modules/
|
||||
*.egg-info/
|
||||
pw-reset/
|
||||
jfa/
|
||||
colors.txt
|
||||
theme.css
|
||||
data/static/bootstrap-jf.css
|
||||
old/
|
||||
|
@ -78,52 +78,27 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if validate %}
|
||||
<div class="col-sm" id="requirementBox">
|
||||
<div class="card bg-light mb-3 requirementBox">
|
||||
<div class="card-header">Password Requirements</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-group">
|
||||
{% for key, value in requirements.items() %}
|
||||
<li id="{{ key }}" class="list-group-item list-group-item-danger">
|
||||
<div> {{ value }}</div>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var code = window.location.href.split('/').pop();
|
||||
$.ajax('/getRequirements', {
|
||||
data : JSON.stringify({ 'code': code }),
|
||||
contentType : 'application/json',
|
||||
type : 'POST',
|
||||
crossDomain : true,
|
||||
complete : function(response){
|
||||
var data = response['responseJSON'];
|
||||
if (Object.keys(data).length > 1) {
|
||||
var col = document.createElement('div');
|
||||
col.classList.add('col-sm');
|
||||
col.id = 'requirementBox';
|
||||
var card = document.createElement('div');
|
||||
card.classList.add('card', 'bg-light', 'mb-3', 'requirementBox');
|
||||
// card.setAttribute('style', 'max-width: 18rem;');
|
||||
var header = document.createElement('div');
|
||||
header.classList.add('card-header');
|
||||
header.appendChild(document.createTextNode('Password Requirements'));
|
||||
card.appendChild(header);
|
||||
var body = document.createElement('div');
|
||||
body.classList.add('card-body');
|
||||
var listGroup = document.createElement('ul');
|
||||
listGroup.classList.add('list-group');
|
||||
listGroup.id = 'requirements';
|
||||
for (var key in data) {
|
||||
if (data.hasOwnProperty(key)) {
|
||||
var criterion = document.createElement('li');
|
||||
criterion.id = key;
|
||||
criterion.classList.add('list-group-item', 'list-group-item-danger');
|
||||
var text = document.createElement('div');
|
||||
text.appendChild(document.createTextNode(' ' + data[key]));
|
||||
criterion.appendChild(text);
|
||||
listGroup.appendChild(criterion);
|
||||
};
|
||||
};
|
||||
body.appendChild(listGroup);
|
||||
card.appendChild(body);
|
||||
col.appendChild(card);
|
||||
document.getElementById('cardContainer').appendChild(col);
|
||||
};
|
||||
}
|
||||
});
|
||||
function toggleSpinner () {
|
||||
var submitButton = document.getElementById('submitButton');
|
||||
var oldSpan = document.getElementById('createAccount');
|
||||
|
@ -3,6 +3,7 @@ from pathlib import Path
|
||||
from flask import Flask, send_from_directory, render_template
|
||||
from __main__ import config, app, g
|
||||
from __main__ import web_log as log
|
||||
from jellyfin_accounts.web_api import checkInvite, validator
|
||||
|
||||
|
||||
@app.errorhandler(404)
|
||||
@ -25,7 +26,6 @@ def static_proxy(path):
|
||||
return render_template('404.html',
|
||||
contactMessage=config['ui']['contact_message']), 404
|
||||
|
||||
from jellyfin_accounts.web_api import checkInvite
|
||||
|
||||
|
||||
@app.route('/invite/<path:path>')
|
||||
@ -48,6 +48,9 @@ def inviteProxy(path):
|
||||
helpMessage=config['ui']['help_message'],
|
||||
successMessage=config['ui']['success_message'],
|
||||
jfLink=config['jellyfin']['server'],
|
||||
validate=config.getboolean('password_validation',
|
||||
'enabled'),
|
||||
requirements=validator.getCriteria(),
|
||||
email=email)
|
||||
elif 'admin.html' not in path and 'admin.html' not in path:
|
||||
return app.send_static_file(path)
|
||||
|
@ -112,14 +112,6 @@ else:
|
||||
validator = PasswordValidator(0, 0, 0, 0, 0)
|
||||
|
||||
|
||||
@app.route('/getRequirements', methods=['GET', 'POST'])
|
||||
def getRequirements():
|
||||
data = request.get_json()
|
||||
log.debug('Password Requirements requested')
|
||||
if checkInvite(data['code']):
|
||||
return jsonify(validator.getCriteria())
|
||||
|
||||
|
||||
@app.route('/newUser', methods=['GET', 'POST'])
|
||||
def newUser():
|
||||
data = request.get_json()
|
||||
|
2
setup.py
2
setup.py
@ -22,10 +22,8 @@ setup(
|
||||
# include_package_data=True,
|
||||
data_files=[('data', ['data/config-default.ini',
|
||||
'data/email.html',
|
||||
'data/email.mjml',
|
||||
'data/email.txt',
|
||||
'data/invite-email.html',
|
||||
'data/invite-email.mjml',
|
||||
'data/invite-email.txt']),
|
||||
('data/static', ['data/static/admin.js',
|
||||
'data/static/setup.js']),
|
||||
|
Loading…
Reference in New Issue
Block a user