merge ldap user and db user, cleanup, add password change
This commit is contained in:
parent
6334c993a9
commit
4150853588
14 changed files with 280 additions and 259 deletions
|
@ -3,10 +3,29 @@
|
|||
const $ = document.querySelector.bind(document)
|
||||
const _ = document.getElementById
|
||||
|
||||
export class ConfirmDialog {
|
||||
export class Dialog {
|
||||
template(){
|
||||
return `
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
constructor(message) {
|
||||
this._div = document.getElementById('confirm-dialog-template').content.querySelector('div').cloneNode(true);
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"></h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary close" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
constructor(title, message) {
|
||||
this._div = (new DOMParser().parseFromString(this.template(), 'text/html')).body.firstChild;
|
||||
this._div.querySelector('.modal-body').innerHTML = message;
|
||||
}
|
||||
|
||||
|
@ -18,21 +37,16 @@ export class ConfirmDialog {
|
|||
});
|
||||
|
||||
this._div.querySelectorAll('.close').forEach(function (o){
|
||||
o.onclick=self.cancel.bind(self);
|
||||
o.onclick=self.close.bind(self);
|
||||
});
|
||||
|
||||
this._div.querySelector('.process').onclick = () => {
|
||||
self._close();
|
||||
self._resolve();
|
||||
};
|
||||
|
||||
$('.messages-box').appendChild(this._div);
|
||||
return this._promise
|
||||
}
|
||||
|
||||
cancel() {
|
||||
close() {
|
||||
this._close()
|
||||
this._reject('canceled by user');
|
||||
this._resolve();
|
||||
}
|
||||
|
||||
_close() {
|
||||
|
@ -43,3 +57,38 @@ export class ConfirmDialog {
|
|||
|
||||
|
||||
|
||||
export class ConfirmDialog extends Dialog {
|
||||
template(){
|
||||
return `
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"></h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-danger close" data-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary btn-ok process">Process</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
show(){
|
||||
this._div.querySelector('.process').onclick = () => {
|
||||
self._close();
|
||||
self._resolve();
|
||||
};
|
||||
return super.show()
|
||||
}
|
||||
|
||||
close() {
|
||||
this._close()
|
||||
this._reject('canceled by user');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'jquery';
|
||||
import 'bootstrap';
|
||||
import 'jquery-form'
|
||||
import {ConfirmDialog} from './confirm-modal.js';
|
||||
import {ConfirmDialog, Dialog} from './confirm-modal.js';
|
||||
|
||||
jQuery = window.$ = window.jQuery = require('jquery');
|
||||
var forge = require('node-forge');
|
||||
|
@ -39,6 +39,7 @@ function randBase32() {
|
|||
}
|
||||
|
||||
window.ConfirmDialog = ConfirmDialog;
|
||||
window.Dialog = Dialog;
|
||||
|
||||
window.$(document).ready(function () {
|
||||
$('#sidebarCollapse').onclick = function () {
|
||||
|
@ -58,7 +59,7 @@ window.totp = {
|
|||
input_secret.value = secret;
|
||||
}
|
||||
|
||||
form.querySelector('#name').on('change',window.totp.generate_qrcode);
|
||||
form.querySelector('#name').onchange=window.totp.generate_qrcode;
|
||||
window.totp.generate_qrcode();
|
||||
},
|
||||
generate_qrcode: function(){
|
||||
|
@ -68,7 +69,13 @@ window.totp = {
|
|||
var issuer = 'Lenticular%20Cloud';
|
||||
var svg_container = $('#svg-container')
|
||||
var svg = new QRCode(`otpauth://totp/${issuer}:${name}?secret=${secret}&issuer=${issuer}`).svg();
|
||||
svg_container.html(svg);
|
||||
var svg_xml =new DOMParser().parseFromString(svg,'text/xml')
|
||||
if(svg_container.childNodes.length > 0) {
|
||||
svg_container.childNodes[0].replaceWith(svg_xml.childNodes[0])
|
||||
} else {
|
||||
svg_container.appendChild(svg_xml.childNodes[0]);
|
||||
}
|
||||
// .innerHtml=svg;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,15 +87,30 @@ window.fido2 = {
|
|||
window.password_change= {
|
||||
init: function(){
|
||||
var form = $('form');
|
||||
SimpleFormSubmit.submitForm(form.action, form)
|
||||
.then(response =>{
|
||||
});
|
||||
form.onsubmit = function () {
|
||||
SimpleFormSubmit.submitForm(form.action, form)
|
||||
.then(response =>{
|
||||
response.json().then(function(data) {
|
||||
if (data.errors) {
|
||||
var msg ='<ul>';
|
||||
for( var field in data.errors) {
|
||||
msg += `<li>${field}: ${data.errors[field]}</li>`;
|
||||
}
|
||||
msg += '</ul>';
|
||||
new Dialog('Password change Error', `Error Happend: ${msg}`).show()
|
||||
} else {
|
||||
new Dialog('Password changed', 'Password changed successfully!').show();
|
||||
}
|
||||
});
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
window.oauth2_token = {
|
||||
revoke: function(href, id){
|
||||
var dialog = new ConfirmDialog(`Are you sure to revoke all tokens from client "${id}"?`);
|
||||
var dialog = new ConfirmDialog('Revoke client tokens', `Are you sure to revoke all tokens from client "${id}"?`);
|
||||
dialog.show().then(()=>{
|
||||
fetch(href, {
|
||||
method: 'DELETE'
|
||||
|
@ -151,7 +173,7 @@ window.client_cert = {
|
|||
});
|
||||
},
|
||||
revoke_certificate: function(href, id){
|
||||
var dialog = new ConfirmDialog(`Are you sure to revoke the certificate with the fingerprint ${id}?`);
|
||||
var dialog = new ConfirmDialog('Revoke client certificate', `Are you sure to revoke the certificate with the fingerprint ${id}?`);
|
||||
dialog.show().then(()=>{
|
||||
fetch(href, {
|
||||
method: 'DELETE'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue