iss #54 - Added authorization check by testDatasource() method.
This commit is contained in:
@@ -46,12 +46,23 @@ function (angular, _, kbn) {
|
|||||||
* @return {object} Connection status and Zabbix API version
|
* @return {object} Connection status and Zabbix API version
|
||||||
*/
|
*/
|
||||||
ZabbixAPIDatasource.prototype.testDatasource = function() {
|
ZabbixAPIDatasource.prototype.testDatasource = function() {
|
||||||
|
var self = this;
|
||||||
return this.zabbixAPI.getZabbixAPIVersion().then(function (apiVersion) {
|
return this.zabbixAPI.getZabbixAPIVersion().then(function (apiVersion) {
|
||||||
|
return self.zabbixAPI.performZabbixAPILogin().then(function (auth) {
|
||||||
|
if (auth) {
|
||||||
return {
|
return {
|
||||||
status: "success",
|
status: "success",
|
||||||
title: "Success",
|
title: "Success",
|
||||||
message: "Zabbix API version: " + apiVersion
|
message: "Zabbix API version: " + apiVersion
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
status: "error",
|
||||||
|
title: "Invalid user name or password",
|
||||||
|
message: "Zabbix API version: " + apiVersion
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user