Commit 510da7c5 authored by Henning Leutz's avatar Henning Leutz 🥋

feat: quiqqer/quiqqer#882 - use frontend users login if user was logged out

parent 024a7e54
......@@ -47,7 +47,8 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [
header : true,
authenticators: [], // fixed list of authenticators shown
mail : true,
passwordReset : true
passwordReset : true,
reload : true
},
initialize: function (options) {
......@@ -232,7 +233,9 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [
return;
}
window.location.reload();
if (self.getAttribute('reload')) {
window.location.reload();
}
}, {
showLogin : false,
authenticator: 'QUI\\Users\\Auth\\QUIQQER',
......@@ -279,6 +282,10 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [
}
QUIAjax.get('package_quiqqer_frontend-users_ajax_frontend_login_getLoginRedirect', function (redirect) {
if (self.getAttribute('reload') === false) {
return;
}
if (redirect) {
window.location = redirect;
return;
......@@ -394,7 +401,13 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Login', [
return;
}
var self = this;
QUIAjax.post('package_quiqqer_frontend-users_ajax_frontend_login_getLoginRedirect', function (result) {
if (self.getAttribute('reload') === false) {
return;
}
if (result) {
window.location = result;
}
......
......@@ -26,7 +26,8 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Window', [
maxHeight: 640,
maxWidth : 500,
buttons : false,
logo : false
logo : false,
reload : true
},
initialize: function (options) {
......@@ -58,7 +59,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Window', [
'class': 'quiqqer-frontendUsers-loginWindow-close',
html : '<span class="fa fa-close"></span>',
events : {
click: this.close.bind(this)
click: this.cancel.bind(this)
}
}).inject(Content);
......@@ -78,6 +79,7 @@ define('package/quiqqer/frontend-users/bin/frontend/controls/login/Window', [
this.$Login = new Login({
showLoader: false,
reload : this.getAttribute('reload'),
onSuccess : function () {
self.close();
self.fireEvent('success', [self]);
......
......@@ -342,50 +342,89 @@ class Events
$User = QUI::getUserBySession();
echo "<script>
(function() {
var registerNewLogin = function() {
require(['qui/QUI'], function(QUI) {
QUI.addEvent('onAjaxLogin', function(QUIAjax, call, method, callback, params) {
require(['package/quiqqer/frontend-users/bin/frontend/controls/login/Window'], function(Window) {
new Window({
reload: false,
events: {
onCancel: function() {
console.log('cancel');
window.location.reload();
},
onSuccess: function() {
QUIAjax.request(call, method, callback, params);
}
}
}).open();
});
return true;
});
});
};
var waitForRequireEventRegister = setInterval(function() {
if (typeof require === 'undefined') {
return;
}
clearInterval(waitForRequireEventRegister);
registerNewLogin();
}, 200);
})();
</script>";
if (!$User->getAttribute('quiqqer.set.new.password')) {
return;
}
echo "<script>
var openChangePasswordWindow = function() {
require([
'controls/users/password/Window',
'Locale'
], function(Password, QUILocale) {
new Password({
uid: '".$User->getId()."',
mustChange: true,
message: QUILocale.get('quiqqer/quiqqer', 'message.set.new.password'),
events: {
onSuccess: function() {
window.location.reload();
(function() {
var openChangePasswordWindow = function() {
require([
'controls/users/password/Window',
'Locale'
], function(Password, QUILocale) {
new Password({
uid: '".$User->getId()."',
mustChange: true,
message: QUILocale.get('quiqqer/quiqqer', 'message.set.new.password'),
events: {
onSuccess: function() {
window.location.reload();
}
}
}).open();
});
};
var checkChangePasswordWindow = function() {
require(['Locale'], function(QUILocale) {
if (!QUILocale.exists('quiqqer/quiqqer', 'message.set.new.password')) {
(function() {
openChangePasswordWindow();
}).delay(2000);
return;
}
}).open();
});
};
var checkChangePasswordWindow = function() {
require(['Locale'], function(QUILocale) {
if (!QUILocale.exists('quiqqer/quiqqer', 'message.set.new.password')) {
(function() {
openChangePasswordWindow();
}).delay(2000);
openChangePasswordWindow();
});
};
var waitForRequire = setInterval(function() {
if (typeof require === 'undefined') {
return;
}
openChangePasswordWindow();
});
};
var waitForRequire = setInterval(function() {
if (typeof require === 'undefined') {
return;
}
clearInterval(waitForRequire);
checkChangePasswordWindow();
}, 200);
clearInterval(waitForRequire);
checkChangePasswordWindow();
}, 200);
})();
</script>";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment