oauth fix

This commit is contained in:
Yuri Kuznetsov
2014-09-19 18:12:44 +03:00
parent 6c56269f18
commit 837b324fe8
@@ -198,6 +198,7 @@ Espo.define('Views.ExternalAccount.OAuth2', 'View', function (Dep) {
var parseUrl = function (str) {
var code = null;
var error = null;
str = str.substr(str.indexOf('?') + 1, str.length);
str.split('&').forEach(function (part) {
@@ -208,11 +209,18 @@ Espo.define('Views.ExternalAccount.OAuth2', 'View', function (Dep) {
if (name == 'code') {
code = value;
}
if (name == 'error') {
error = value;
}
}, this);
if (code) {
return {
code: code,
}
} else if (error) {
return {
error: error,
}
}
}
@@ -244,6 +252,10 @@ Espo.define('Views.ExternalAccount.OAuth2', 'View', function (Dep) {
approval_prompt: 'force'
}
}, function (res) {
if (res.errror) {
this.notify(false);
return;
}
if (res.code) {
this.$el.find('[data-action="connect"]').addClass('disabled');
$.ajax({