Skip to content
Snippets Groups Projects
Commit f44c2227 authored by Cam Saul's avatar Cam Saul
Browse files

:scream: check for valid DB connection before update in admin

parent 38658568
No related branches found
No related tags found
No related merge requests found
......@@ -88,15 +88,23 @@ DatabasesControllers.controller('DatabaseEdit', ['$scope', '$routeParams', '$loc
if (redirectToDetail === undefined) {
redirectToDetail = true;
}
// validate_connection needs engine so add it to request body
details.engine = database.engine;
// for an existing DB check that connection is valid before save
if ($routeParams.databaseId) {
return update(database, details);
return Metabase.validate_connection(details).$promise.catch(function(error) {
$scope.$broadcast("form:api-error", error);
throw error;
}).then(function() {
return update(database, details);
});
// for a new DB we want to infer SSL support. First try to connect w/ SSL. If that fails, disable SSL
} else {
// for a new DB we want to infer SSL support. First try to connect w/ SSL. If that fails, disable SSL
details.ssl = true;
// add 'engine' to the request body
details.engine = database.engine;
return Metabase.validate_connection(details).$promise.catch(function() {
console.log('Unable to connect with SSL. Trying with SSL = false.');
details.ssl = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment