Commit 04473632 authored by Henning Leutz's avatar Henning Leutz 🥋

feat: User Login Logout - added global QUI events

parent e1c87c6d
/**
* @module controls/users/Login
*
* @event onLoad
* @event onAuthBegin
* @event onAuthNext
* @event onSuccess
* @event onAuthNext
* @event onUserLoginError [error, this]
* @event onLoad [self]
* @event onAuthBegin [self]
* @event onAuthNext [self]
* @event onSuccess [self]
* @event onUserLoginError [error, self]
*
* @event quiqqerUserAuthLoginLoad [self]
* @event quiqqerUserAuthLoginUserLoginError [error, self]
* @event quiqqerUserAuthLoginAuthBegin [self]
* @event quiqqerUserAuthLoginSuccess [self]
* @event quiqqerUserAuthNext [self]
*/
define('controls/users/Login', [
......@@ -91,6 +96,7 @@ define('controls/users/Login', [
QUIAjax.get('ajax_users_loginControl', function (result) {
self.$buildAuthenticator(result).then(function () {
self.fireEvent('load', [self]);
QUI.fireEvent('quiqqerUserAuthLoginLoad', [self]);
});
}, {
isAdminLogin : typeof QUIQQER_IS_ADMIN_LOGIN !== 'undefined' ? 1 : 0,
......@@ -111,6 +117,7 @@ define('controls/users/Login', [
this.$refreshForm();
this.fireEvent('load', [this]);
QUI.fireEvent('quiqqerUserAuthLoginLoad', [this]);
},
/**
......@@ -142,6 +149,7 @@ define('controls/users/Login', [
this.auth(Target).catch(function (err) {
self.fireEvent('userLoginError', [err, self]);
QUI.fireEvent('quiqqerUserAuthLoginUserLoginError', [err, self]);
});
}.bind(this)
}
......@@ -225,6 +233,7 @@ define('controls/users/Login', [
}
this.fireEvent('authBegin', [this]);
QUI.fireEvent('quiqqerUserAuthLoginAuthBegin', [this]);
return new Promise(function (resolve, reject) {
QUIAjax.post('ajax_users_login', function (result) {
......@@ -233,6 +242,7 @@ define('controls/users/Login', [
window.QUIQQER_USER = result.user;
self.fireEvent('success', [self]);
QUI.fireEvent('quiqqerUserAuthLoginSuccess', [self]);
resolve(self);
if (typeof self.getAttribute('onSuccess') === 'function') {
......@@ -277,7 +287,8 @@ define('controls/users/Login', [
),
onError : function (e) {
self.Loader.hide();
self.fireEvent('authNext', [this]);
self.fireEvent('authNext', [self]);
QUI.fireEvent('quiqqerUserAuthNext', [self]);
reject(e);
}
......
......@@ -4,10 +4,7 @@
* @author www.pcsg.de (Henning Leutz)
* @module controls/users/LogoutWindow
*
* @require qui/QUI
* @require qui/controls/windows/Confirm
* @require controls/users/Login
* @require Locale
* @event onQuiqqerUserAuthLogout
*/
define('controls/users/LogoutWindow', [
......@@ -64,6 +61,8 @@ define('controls/users/LogoutWindow', [
this.Loader.show();
Ajax.post('ajax_users_logout', function () {
QUI.fireEvent('quiqqerUserAuthLogout');
if (window.location.hash !== '') {
window.location.reload();
return;
......
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