mirror of
https://github.com/openwrt/luci.git
synced 2025-02-06 23:59:53 +00:00
Use an traditional HTML form with post submit action to the same URL in order to simplify the login process and not rely on the discarded login XHR reply properly setting the login cookie. This will also avoid one useless request on login and hopefully fix login issues reported with various browser environments. As a bonus, the resulting code is somewhat smaller as well. Ref: https://forum.openwrt.org/t/login-does-not-work/113360 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
35 lines
756 B
JavaScript
35 lines
756 B
JavaScript
'use strict';
|
|
'require ui';
|
|
'require view';
|
|
|
|
return view.extend({
|
|
render: function() {
|
|
var form = document.querySelector('form'),
|
|
btn = document.querySelector('button');
|
|
|
|
var dlg = ui.showModal(
|
|
_('Authorization Required'),
|
|
[].slice.call(document.querySelectorAll('section > *')),
|
|
'login'
|
|
);
|
|
|
|
form.addEventListener('keypress', function(ev) {
|
|
if (ev.key == 'Enter')
|
|
btn.click();
|
|
});
|
|
|
|
btn.addEventListener('click', function() {
|
|
dlg.querySelectorAll('*').forEach(function(node) { node.style.display = 'none' });
|
|
dlg.appendChild(E('div', { 'class': 'spinning' }, _('Logging in…')));
|
|
|
|
form.submit()
|
|
});
|
|
|
|
document.querySelector('input[type="password"]').focus();
|
|
|
|
return '';
|
|
},
|
|
|
|
addFooter: function() {}
|
|
});
|