From 895a2f7f2f0efcf92385f3399e214460edd9e989 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 23 Sep 2022 15:49:08 +0300 Subject: [PATCH] ref --- client/src/views/login-second-step.js | 21 ++++++++++++++++----- client/src/views/login.js | 21 ++++++++++++++++----- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/client/src/views/login-second-step.js b/client/src/views/login-second-step.js index 38a1dc3f78..be75459af4 100644 --- a/client/src/views/login-second-step.js +++ b/client/src/views/login-second-step.js @@ -137,11 +137,7 @@ define('views/login-second-step', ['view'], function (Dep) { .then(data => { Espo.Ui.notify(false); - if (this.anotherUser) { - data.anotherUser = this.anotherUser; - } - - this.trigger('login', userName, data); + this.triggerLogin(userName, data); }) .catch(xhr => { this.undisableForm(); @@ -152,6 +148,21 @@ define('views/login-second-step', ['view'], function (Dep) { }); }, + /** + * Trigger login to proceed to the application. + * + * @public + * @param {string} userName A username. + * @param {Object.} data Data returned from the `App/user` request. + */ + triggerLogin: function (userName, data) { + if (this.anotherUser) { + data.anotherUser = this.anotherUser; + } + + this.trigger('login', userName, data); + }, + /** * @private */ diff --git a/client/src/views/login.js b/client/src/views/login.js index 1d5de5b194..5b579c03e5 100644 --- a/client/src/views/login.js +++ b/client/src/views/login.js @@ -170,11 +170,7 @@ define('views/login', ['view'], function (Dep) { .then(data => { Espo.Ui.notify(false); - if (this.anotherUser) { - data.anotherUser = this.anotherUser; - } - - this.trigger('login', userName, data); + this.triggerLogin(userName, data); }) .catch(xhr => { this.undisableForm(); @@ -195,6 +191,21 @@ define('views/login', ['view'], function (Dep) { }); }, + /** + * Trigger login to proceed to the application. + * + * @public + * @param {string} userName A username. + * @param {Object.} data Data returned from the `App/user` request. + */ + triggerLogin: function (userName, data) { + if (this.anotherUser) { + data.anotherUser = this.anotherUser; + } + + this.trigger('login', userName, data); + }, + /** * @private */