summaryrefslogtreecommitdiffstats
path: root/modules-available/adduser
diff options
context:
space:
mode:
authorSimon Rettberg2018-04-09 18:09:07 +0200
committerSimon Rettberg2018-04-09 18:09:07 +0200
commit1a4c38fddc0003ca36e2c3838b5a4c9233d51a35 (patch)
treea2a3717f1571e1b67257fd97c68561517505298c /modules-available/adduser
parent[adduser] Rename permission to view-list (diff)
downloadslx-admin-1a4c38fddc0003ca36e2c3838b5a4c9233d51a35.tar.gz
slx-admin-1a4c38fddc0003ca36e2c3838b5a4c9233d51a35.tar.xz
slx-admin-1a4c38fddc0003ca36e2c3838b5a4c9233d51a35.zip
[adduser] JS checks while editing user; second save button below role list
Diffstat (limited to 'modules-available/adduser')
-rw-r--r--modules-available/adduser/page.inc.php5
-rw-r--r--modules-available/adduser/templates/js-add-edit.html26
-rw-r--r--modules-available/adduser/templates/page-adduser.html32
-rw-r--r--modules-available/adduser/templates/page-edituser.html14
-rw-r--r--modules-available/adduser/templates/user-permissions.html12
5 files changed, 55 insertions, 34 deletions
diff --git a/modules-available/adduser/page.inc.php b/modules-available/adduser/page.inc.php
index 3af4ea6d..e95cb78a 100644
--- a/modules-available/adduser/page.inc.php
+++ b/modules-available/adduser/page.inc.php
@@ -106,7 +106,7 @@ class Page_AddUser extends Page
if ($ret > 0) {
Message::addSuccess('user-edited');
}
- if (!empty($pass1)) {
+ if (!empty($pass1) && $userid !== User::getId()) {
$data = [
'pass' => Crypto::hash6($pass1),
'userid' => $userid,
@@ -168,6 +168,7 @@ class Page_AddUser extends Page
}
Render::openTag('form', ['class' => 'form-adduser', 'action' => '?do=adduser', 'method' => 'post']);
Render::addTemplate('page-adduser');
+ Render::addTemplate('js-add-edit');
if ($hasUsers) {
$this->showRoles();
}
@@ -184,9 +185,11 @@ class Page_AddUser extends Page
if ($user === false) {
Message::addError('user-not-found', $userid);
} else {
+ $user['password_disabled'] = User::getId() === $userid ? 'disabled' : false;
// TODO: LDAP -> disallow pw change, maybe other fields too?
Render::openTag('form', ['class' => 'form-adduser', 'action' => '?do=adduser', 'method' => 'post']);
Render::addTemplate('page-edituser', $user);
+ Render::addTemplate('js-add-edit');
$this->showRoles($userid);
Render::closeTag('form');
}
diff --git a/modules-available/adduser/templates/js-add-edit.html b/modules-available/adduser/templates/js-add-edit.html
new file mode 100644
index 00000000..95454c22
--- /dev/null
+++ b/modules-available/adduser/templates/js-add-edit.html
@@ -0,0 +1,26 @@
+<script><!--
+document.addEventListener('DOMContentLoaded', function() {
+ var $login = $('#login');
+ var $pass1 = $('#pass1');
+ var $pass2 = $('#pass2');
+ var $fullname = $('#fullname');
+ var $msg = $('#add-msg');
+ var $btn = $('.save-btn');
+ var ev = function() {
+ var msg = '';
+ if ($login.val().length < 2) {
+ msg = '{{lang_loginTooShort}}';
+ } else if ($pass1.val() !== $pass2.val()) {
+ msg = '{{lang_passwordsDontMatch}}';
+ } else if ((!SLX_EDITUSER || $pass1.val().length > 0) && $pass1.val().length < 2) {
+ msg = '{{lang_passwordTooShort}}';
+ } else if ($fullname.val().length < 1) {
+ msg = '{{lang_fullnameMissing}}';
+ }
+ $msg.text(msg);
+ $btn.prop('disabled', !!msg);
+ };
+ $('.event-box').change(ev).keyup(ev);
+ if (SLX_EDITUSER) ev();
+});
+//--></script> \ No newline at end of file
diff --git a/modules-available/adduser/templates/page-adduser.html b/modules-available/adduser/templates/page-adduser.html
index 18d79a3b..08587373 100644
--- a/modules-available/adduser/templates/page-adduser.html
+++ b/modules-available/adduser/templates/page-adduser.html
@@ -30,34 +30,12 @@
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-8">
- <button id="add-btn" class="btn btn-lg btn-primary btn-block" type="submit" disabled>{{lang_createUser}}</button>
+ <button class="btn btn-lg btn-primary btn-block save-btn" type="submit" disabled>
+ <span class="glyphicon glyphicon-floppy-disk"></span>
+ {{lang_createUser}}
+ </button>
<div id="add-msg" class="text-danger slx-bold"></div>
</div>
</div>
<input type="hidden" name="action" value="adduser">
-<input type="hidden" name="token" value="{{token}}">
-<script><!--
-document.addEventListener('DOMContentLoaded', function() {
- var $login = $('#login');
- var $pass1 = $('#pass1');
- var $pass2 = $('#pass2');
- var $fullname = $('#fullname');
- var $msg = $('#add-msg');
- var $btn = $('#add-btn');
- var ev = function() {
- var msg = '';
- if ($login.val().length < 2) {
- msg = '{{lang_loginTooShort}}';
- } else if ($pass1.val() !== $pass2.val()) {
- msg = '{{lang_passwordsDontMatch}}';
- } else if ($pass1.val().length < 2) {
- msg = '{{lang_passwordTooShort}}';
- } else if ($fullname.val().length < 1) {
- msg = '{{lang_fullnameMissing}}';
- }
- $msg.text(msg);
- $btn.prop('disabled', !!msg);
- };
- $('.event-box').change(ev).keyup(ev);
-});
-//--></script> \ No newline at end of file
+<input type="hidden" name="token" value="{{token}}"> \ No newline at end of file
diff --git a/modules-available/adduser/templates/page-edituser.html b/modules-available/adduser/templates/page-edituser.html
index 36293b11..68376213 100644
--- a/modules-available/adduser/templates/page-edituser.html
+++ b/modules-available/adduser/templates/page-edituser.html
@@ -4,7 +4,7 @@
<div class="row">
<div class="col-md-4"><label for="login">{{lang_login}}</label></div>
- <div class="col-md-4"><input id="label" type="text" name="login" value="{{login}}" class="form-control"
+ <div class="col-md-4"><input id="login" type="text" name="login" value="{{login}}" class="form-control event-box"
placeholder="{{lang_username}}" autofocus></div>
</div>
<div class="row">
@@ -18,9 +18,9 @@
<div class="row">
<div class="col-md-4"><label for="pass1">{{lang_changePassword}}</label></div>
- <div class="col-md-4"><input id="pass1" {{password_disabled}} type="password" name="pass1" class="form-control" placeholder="{{lang_password}}">
+ <div class="col-md-4"><input id="pass1" {{password_disabled}} type="password" name="pass1" class="form-control event-box" placeholder="{{lang_password}}">
</div>
- <div class="col-md-4"><input {{password_disabled}} type="password" name="pass2" class="form-control"
+ <div class="col-md-4"><input id="pass2" {{password_disabled}} type="password" name="pass2" class="form-control event-box"
placeholder="{{lang_confirmation}}"></div>
</div>
{{#password_disabled}}
@@ -37,7 +37,7 @@
<div class="row">
<div class="col-md-4"><label for="fullname">{{lang_fullName}}</label></div>
- <div class="col-md-4"><input id="fullname" type="text" name="fullname" value="{{fullname}}" class="form-control"
+ <div class="col-md-4"><input id="fullname" type="text" name="fullname" value="{{fullname}}" class="form-control event-box"
placeholder="{{lang_fullName}}"></div>
</div>
<br>
@@ -59,12 +59,16 @@
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-8">
- <button class="btn btn-lg btn-primary btn-block" type="submit">
+ <button class="btn btn-lg btn-primary btn-block save-btn" type="submit">
<span class="glyphicon glyphicon-floppy-disk"></span>
{{lang_save}}
</button>
+ <div id="add-msg" class="text-danger slx-bold"></div>
</div>
</div>
<input type="hidden" name="action" value="edituser">
<input type="hidden" name="userid" value="{{userid}}">
<input type="hidden" name="token" value="{{token}}">
+<script>
+ const SLX_EDITUSER = true;
+</script>
diff --git a/modules-available/adduser/templates/user-permissions.html b/modules-available/adduser/templates/user-permissions.html
index ce51630f..11ebd77a 100644
--- a/modules-available/adduser/templates/user-permissions.html
+++ b/modules-available/adduser/templates/user-permissions.html
@@ -21,4 +21,14 @@
</tr>
{{/roles}}
</tbody>
-</table> \ No newline at end of file
+</table>
+
+<div class="row">
+ <div class="col-md-4"></div>
+ <div class="col-md-8">
+ <button class="btn btn-lg btn-primary btn-block save-btn" type="submit">
+ <span class="glyphicon glyphicon-floppy-disk"></span>
+ {{lang_save}}
+ </button>
+ </div>
+</div> \ No newline at end of file