From 3cc75c2dfdd064d86f724ecca84f7c4821d402f1 Mon Sep 17 00:00:00 2001 From: Andreas <andreasv@fsmpi.rwth-aachen.de> Date: Sun, 21 May 2017 01:38:02 +0200 Subject: [PATCH] added password generator function to permission editor, closes #265 --- static/moderator.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/static/moderator.js b/static/moderator.js index 2444947..dec55f9 100644 --- a/static/moderator.js +++ b/static/moderator.js @@ -191,8 +191,11 @@ var moderator = { html += '<option value="none">Kein Zugriff</option>'; html += '</select>'; html += '<input class="col-xs-12 passwordinput authuser" type="text" placeholder="Benutzername">'; - html += '<input class="col-xs-12 passwordinput authpassword" type="text" placeholder="Passwort">'; + html += '<input class="col-xs-10 passwordinput authpassword" type="text" placeholder="Passwort">' + html += '<button class="col-xs-2 passwordinput authpgen" type="button" onclick="$(\'.authpassword\',this.parentNode).val(moderator.permissioneditor.randompw());"><span class="fa fa-plus" aria-hidden="true"></span></button>' + html += '<input class="col-xs-12 authl2p" type="text" placeholder="Lernraum" style="display: none;">'; + html += '<button class="col-xs-6" onclick="moderator.permissioneditor.addbtnclick(this)">Add</button>'; //html += '<button class="col-xs-4" onclick="moderator.permissionedior.updatebtnclick(this)">Update</button>'; html += '<button class="col-xs-6" onclick="moderator.permissioneditor.delbtnclick(this)">Delete</button>'; @@ -248,6 +251,15 @@ var moderator = { $(".authl2p",element.parentElement).hide(); break; } + }, + randompw: function () {; + var array = new Uint8Array(10); + window.crypto.getRandomValues(array); + var result = ''; + for (var i = 0; i< array.length; i++) { + result += String.fromCharCode(48+ (array[i]/255.0)*74); + } + return result; } }, plots: { -- GitLab