diff --git a/ogcp/forms/auth.py b/ogcp/forms/auth.py
index c02ecc7..b10d8fe 100644
--- a/ogcp/forms/auth.py
+++ b/ogcp/forms/auth.py
@@ -7,7 +7,7 @@
from wtforms import (
Form, SubmitField, HiddenField, SelectField, BooleanField, IntegerField,
- StringField, RadioField, PasswordField
+ StringField, RadioField, PasswordField, SelectMultipleField
)
from wtforms.validators import InputRequired
from flask_wtf import FlaskForm
@@ -28,3 +28,32 @@ class LoginForm(FlaskForm):
submit_btn = SubmitField(
label=_l('Login')
)
+
+
+class UserForm(FlaskForm):
+ username = StringField(
+ label=_l('Username'),
+ validators=[InputRequired()]
+ )
+ pwd = PasswordField(
+ label=_l('Password'),
+ )
+ pwd_hash = HiddenField(
+ validators=[InputRequired()]
+ )
+ pwd_confirm = PasswordField(
+ label=_l('Repeat password'),
+ )
+ pwd_hash_confirm = HiddenField(
+ validators=[InputRequired()]
+ )
+ admin = BooleanField(
+ label=_l('Administrator'),
+ )
+ scopes = SelectMultipleField(
+ label=_l('Allowed scopes'),
+ description=_l('Leave this empty to give full permissions'),
+ )
+ submit_btn = SubmitField(
+ label=_l('Submit')
+ )
diff --git a/ogcp/static/js/ogcp.js b/ogcp/static/js/ogcp.js
index 6a7e625..4605e5d 100644
--- a/ogcp/static/js/ogcp.js
+++ b/ogcp/static/js/ogcp.js
@@ -231,3 +231,25 @@ function digestLoginPassword() {
$(this).submit()
});
}
+
+function digestUserFormPassword() {
+ const loginForm = $('#user-form')
+ loginForm.one('submit', async function (event) {
+ event.preventDefault()
+
+ const pwdInput = $('#pwd');
+ const pwdHashInput = $('#pwd_hash');
+ const pwdStr = pwdInput.val();
+ const pwdStrHash = await digestMessage(pwdStr);
+
+ const pwdConfirmInput = $('#pwd_confirm');
+ const pwdHashConfirmInput = $('#pwd_hash_confirm');
+ const pwdConfirmStr = pwdConfirmInput.val();
+ const pwdConfirmStrHash = await digestMessage(pwdConfirmStr);
+
+ pwdInput.prop( "disabled", true );
+ pwdHashInput.val(pwdStrHash);
+ pwdHashConfirmInput.val(pwdConfirmStrHash);
+ $(this).submit()
+ });
+}
diff --git a/ogcp/templates/auth/add_user.html b/ogcp/templates/auth/add_user.html
new file mode 100644
index 0000000..af44caa
--- /dev/null
+++ b/ogcp/templates/auth/add_user.html
@@ -0,0 +1,26 @@
+{% extends 'users.html' %}
+{% import "bootstrap/wtf.html" as wtf %}
+
+{% set sidebar_state = 'disabled' %}
+{% set btn_back = true %}
+
+{% block nav_user_add %}active{% endblock %}
+{% block content %}
+
+
{{_('Add a user')}}
+
+{{ wtf.quick_form(form,
+ action=url_for('user_add_post'),
+ method='post',
+ button_map={'submit_btn':'primary'},
+ id='user-form') }}
+
+
+
+{% endblock %}
diff --git a/ogcp/templates/users.html b/ogcp/templates/users.html
index c97f113..c14aae6 100644
--- a/ogcp/templates/users.html
+++ b/ogcp/templates/users.html
@@ -24,6 +24,8 @@
{% endblock %}
{% block commands %}
+
{% if btn_back %}