cs fix
This commit is contained in:
@@ -33,34 +33,35 @@ define('controllers/base', 'controller', function (Dep) {
|
|||||||
login: function () {
|
login: function () {
|
||||||
var viewName = this.getConfig().get('loginView') || 'views/login';
|
var viewName = this.getConfig().get('loginView') || 'views/login';
|
||||||
|
|
||||||
this.entire(viewName, {}, function (loginView) {
|
this.entire(viewName, {}, loginView => {
|
||||||
loginView.render();
|
loginView.render();
|
||||||
|
|
||||||
loginView.on('login', function (userName, data) {
|
loginView.on('login', (userName, data) => {
|
||||||
this.trigger('login', this.normalizeLoginData(userName, data));
|
this.trigger('login', this.normalizeLoginData(userName, data));
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
loginView.once('redirect', function (viewName, userName, password, data) {
|
loginView.once('redirect', (viewName, userName, password, data) => {
|
||||||
loginView.remove();
|
loginView.remove();
|
||||||
|
|
||||||
this.entire(viewName, {
|
this.entire(viewName, {
|
||||||
loginData: data,
|
loginData: data,
|
||||||
userName: userName,
|
userName: userName,
|
||||||
password: password,
|
password: password,
|
||||||
}, function (secondStepView) {
|
}, secondStepView => {
|
||||||
secondStepView.render();
|
secondStepView.render();
|
||||||
|
|
||||||
secondStepView.once('login', function (userName, data) {
|
secondStepView.once('login', (userName, data) => {
|
||||||
this.trigger('login', this.normalizeLoginData(userName, data));
|
this.trigger('login', this.normalizeLoginData(userName, data));
|
||||||
}, this);
|
});
|
||||||
|
|
||||||
secondStepView.once('back', function () {
|
secondStepView.once('back', () => {
|
||||||
secondStepView.remove();
|
secondStepView.remove();
|
||||||
|
|
||||||
this.login();
|
this.login();
|
||||||
}, this);
|
});
|
||||||
}.bind(this));
|
});
|
||||||
}, this);
|
});
|
||||||
}.bind(this));
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
normalizeLoginData: function (userName, data) {
|
normalizeLoginData: function (userName, data) {
|
||||||
@@ -84,6 +85,7 @@ define('controllers/base', 'controller', function (Dep) {
|
|||||||
logout: function () {
|
logout: function () {
|
||||||
var title = this.getConfig().get('applicationName') || 'EspoCRM';
|
var title = this.getConfig().get('applicationName') || 'EspoCRM';
|
||||||
$('head title').text(title);
|
$('head title').text(title);
|
||||||
|
|
||||||
this.trigger('logout');
|
this.trigger('logout');
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -98,22 +100,21 @@ define('controllers/base', 'controller', function (Dep) {
|
|||||||
clearCache: function () {
|
clearCache: function () {
|
||||||
this.entire('views/clear-cache', {
|
this.entire('views/clear-cache', {
|
||||||
cache: this.getCache()
|
cache: this.getCache()
|
||||||
}, function (view) {
|
}, (view) => {
|
||||||
view.render();
|
view.render();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
error404: function () {
|
error404: function () {
|
||||||
this.entire('views/base', {template: 'errors/404'}, function (view) {
|
this.entire('views/base', {template: 'errors/404'}, (view) => {
|
||||||
view.render();
|
view.render();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
error403: function () {
|
error403: function () {
|
||||||
this.entire('views/base', {template: 'errors/403'}, function (view) {
|
this.entire('views/base', {template: 'errors/403'}, (view) => {
|
||||||
view.render();
|
view.render();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ define('views/login-second-step', 'view', function (Dep) {
|
|||||||
events: {
|
events: {
|
||||||
'submit #login-form': function (e) {
|
'submit #login-form': function (e) {
|
||||||
this.send();
|
this.send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
'click [data-action="backToLogin"]': function () {
|
'click [data-action="backToLogin"]': function () {
|
||||||
@@ -60,7 +61,10 @@ define('views/login-second-step', 'view', function (Dep) {
|
|||||||
},
|
},
|
||||||
|
|
||||||
send: function () {
|
send: function () {
|
||||||
var code = $('[data-name="field-code"]').val().trim().replace(/\s/g, '');
|
var code = $('[data-name="field-code"]')
|
||||||
|
.val()
|
||||||
|
.trim()
|
||||||
|
.replace(/\s/g, '');
|
||||||
|
|
||||||
var userName = this.options.userName;
|
var userName = this.options.userName;
|
||||||
var password = this.options.loginData.token || this.options.password;
|
var password = this.options.loginData.token || this.options.password;
|
||||||
@@ -68,8 +72,8 @@ define('views/login-second-step', 'view', function (Dep) {
|
|||||||
var $submit = this.$el.find('#btn-send');
|
var $submit = this.$el.find('#btn-send');
|
||||||
|
|
||||||
if (code == '') {
|
if (code == '') {
|
||||||
|
|
||||||
this.isPopoverDestroyed = false;
|
this.isPopoverDestroyed = false;
|
||||||
|
|
||||||
var $el = $("#field-code");
|
var $el = $("#field-code");
|
||||||
|
|
||||||
var message = this.getLanguage().translate('codeIsRequired', 'messages', 'User');
|
var message = this.getLanguage().translate('codeIsRequired', 'messages', 'User');
|
||||||
@@ -82,13 +86,20 @@ define('views/login-second-step', 'view', function (Dep) {
|
|||||||
}).popover('show');
|
}).popover('show');
|
||||||
|
|
||||||
var $cell = $el.closest('.form-group');
|
var $cell = $el.closest('.form-group');
|
||||||
|
|
||||||
$cell.addClass('has-error');
|
$cell.addClass('has-error');
|
||||||
$el.one('mousedown click', function () {
|
|
||||||
|
$el.one('mousedown click', () => {
|
||||||
$cell.removeClass('has-error');
|
$cell.removeClass('has-error');
|
||||||
if (this.isPopoverDestroyed) return;
|
|
||||||
|
if (this.isPopoverDestroyed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$el.popover('destroy');
|
$el.popover('destroy');
|
||||||
|
|
||||||
this.isPopoverDestroyed = true;
|
this.isPopoverDestroyed = true;
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -97,38 +108,38 @@ define('views/login-second-step', 'view', function (Dep) {
|
|||||||
|
|
||||||
Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
|
Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
|
||||||
|
|
||||||
Espo.Ajax.getRequest('App/user', {code: code}, {
|
Espo.Ajax
|
||||||
login: true,
|
.getRequest('App/user', {code: code}, {
|
||||||
headers: {
|
login: true,
|
||||||
'Authorization': 'Basic ' + base64.encode(userName + ':' + password),
|
headers: {
|
||||||
'Espo-Authorization': base64.encode(userName + ':' + password),
|
'Authorization': 'Basic ' + base64.encode(userName + ':' + password),
|
||||||
'Espo-Authorization-Code': code,
|
'Espo-Authorization': base64.encode(userName + ':' + password),
|
||||||
'Espo-Authorization-Create-Token-Secret': true,
|
'Espo-Authorization-Code': code,
|
||||||
},
|
'Espo-Authorization-Create-Token-Secret': true,
|
||||||
}).then(
|
},
|
||||||
function (data) {
|
})
|
||||||
|
.then(data => {
|
||||||
this.notify(false);
|
this.notify(false);
|
||||||
this.trigger('login', userName, data);
|
this.trigger('login', userName, data);
|
||||||
}.bind(this)
|
})
|
||||||
).fail(
|
.catch(xhr => {
|
||||||
function (xhr) {
|
|
||||||
$submit.removeClass('disabled').removeAttr('disabled');
|
$submit.removeClass('disabled').removeAttr('disabled');
|
||||||
|
|
||||||
if (xhr.status == 401) {
|
if (xhr.status === 401) {
|
||||||
this.onWrongCredentials();
|
this.onWrongCredentials();
|
||||||
}
|
}
|
||||||
}.bind(this)
|
});
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onWrongCredentials: function () {
|
onWrongCredentials: function () {
|
||||||
var cell = $('#login .form-group');
|
var cell = $('#login .form-group');
|
||||||
cell.addClass('has-error');
|
cell.addClass('has-error');
|
||||||
this.$el.one('mousedown click', function () {
|
|
||||||
|
this.$el.one('mousedown click', () => {
|
||||||
cell.removeClass('has-error');
|
cell.removeClass('has-error');
|
||||||
});
|
});
|
||||||
|
|
||||||
Espo.Ui.error(this.translate('wrongCode', 'messages', 'User'));
|
Espo.Ui.error(this.translate('wrongCode', 'messages', 'User'));
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
+20
-21
@@ -45,7 +45,7 @@ define('views/login', 'view', function (Dep) {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
'click a[data-action="passwordChangeRequest"]': function (e) {
|
'click a[data-action="passwordChangeRequest"]': function () {
|
||||||
this.showPasswordChangeRequest();
|
this.showPasswordChangeRequest();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -99,7 +99,7 @@ define('views/login', 'view', function (Dep) {
|
|||||||
|
|
||||||
$cell.addClass('has-error');
|
$cell.addClass('has-error');
|
||||||
|
|
||||||
$el.one('mousedown click', function () {
|
$el.one('mousedown click', () => {
|
||||||
$cell.removeClass('has-error');
|
$cell.removeClass('has-error');
|
||||||
|
|
||||||
if (this.isPopoverDestroyed) {
|
if (this.isPopoverDestroyed) {
|
||||||
@@ -109,7 +109,7 @@ define('views/login', 'view', function (Dep) {
|
|||||||
$el.popover('destroy');
|
$el.popover('destroy');
|
||||||
|
|
||||||
this.isPopoverDestroyed = true;
|
this.isPopoverDestroyed = true;
|
||||||
}.bind(this));
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -118,25 +118,25 @@ define('views/login', 'view', function (Dep) {
|
|||||||
|
|
||||||
Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
|
Espo.Ui.notify(this.translate('pleaseWait', 'messages'));
|
||||||
|
|
||||||
Espo.Ajax.getRequest('App/user', null, {
|
Espo.Ajax
|
||||||
login: true,
|
.getRequest('App/user', null, {
|
||||||
headers: {
|
login: true,
|
||||||
'Authorization': 'Basic ' + base64.encode(userName + ':' + password),
|
headers: {
|
||||||
'Espo-Authorization': base64.encode(userName + ':' + password),
|
'Authorization': 'Basic ' + base64.encode(userName + ':' + password),
|
||||||
'Espo-Authorization-By-Token': false,
|
'Espo-Authorization': base64.encode(userName + ':' + password),
|
||||||
'Espo-Authorization-Create-Token-Secret': true,
|
'Espo-Authorization-By-Token': false,
|
||||||
},
|
'Espo-Authorization-Create-Token-Secret': true,
|
||||||
}).then(
|
},
|
||||||
function (data) {
|
})
|
||||||
|
.then(data => {
|
||||||
this.notify(false);
|
this.notify(false);
|
||||||
|
|
||||||
this.trigger('login', userName, data);
|
this.trigger('login', userName, data);
|
||||||
}.bind(this)
|
})
|
||||||
).fail(
|
.catch(xhr => {
|
||||||
function (xhr) {
|
|
||||||
$submit.removeClass('disabled').removeAttr('disabled');
|
$submit.removeClass('disabled').removeAttr('disabled');
|
||||||
|
|
||||||
if (xhr.status == 401) {
|
if (xhr.status === 401) {
|
||||||
var data = xhr.responseJSON || {};
|
var data = xhr.responseJSON || {};
|
||||||
|
|
||||||
var statusReason = xhr.getResponseHeader('X-Status-Reason');
|
var statusReason = xhr.getResponseHeader('X-Status-Reason');
|
||||||
@@ -151,8 +151,7 @@ define('views/login', 'view', function (Dep) {
|
|||||||
|
|
||||||
this.onWrongCredentials();
|
this.onWrongCredentials();
|
||||||
}
|
}
|
||||||
}.bind(this)
|
});
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onSecondStepRequired: function (userName, password, data) {
|
onSecondStepRequired: function (userName, password, data) {
|
||||||
@@ -166,7 +165,7 @@ define('views/login', 'view', function (Dep) {
|
|||||||
|
|
||||||
cell.addClass('has-error');
|
cell.addClass('has-error');
|
||||||
|
|
||||||
this.$el.one('mousedown click', function () {
|
this.$el.one('mousedown click', () => {
|
||||||
cell.removeClass('has-error');
|
cell.removeClass('has-error');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -178,7 +177,7 @@ define('views/login', 'view', function (Dep) {
|
|||||||
|
|
||||||
this.createView('passwordChangeRequest', 'views/modals/password-change-request', {
|
this.createView('passwordChangeRequest', 'views/modals/password-change-request', {
|
||||||
url: window.location.href,
|
url: window.location.href,
|
||||||
}, function (view) {
|
}, (view) => {
|
||||||
view.render();
|
view.render();
|
||||||
|
|
||||||
Espo.Ui.notify(false);
|
Espo.Ui.notify(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user