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 */