Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
Fix issue #474 concerning NO_AUTH setting when using a database
Browse files Browse the repository at this point in the history
  • Loading branch information
pantsel committed Oct 19, 2019
1 parent 801ac94 commit b012b08
Show file tree
Hide file tree
Showing 6 changed files with 239 additions and 225 deletions.
4 changes: 0 additions & 4 deletions api/controllers/KongNodeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ module.exports = _.merge(_.cloneDeep(require('../base/Controller')), {


create : function(req,res) {

sails.models.kongnode.create(req.body)
.exec(function(err, node){
if(err) {
Expand Down Expand Up @@ -75,9 +74,6 @@ module.exports = _.merge(_.cloneDeep(require('../base/Controller')), {
return res.created(node);
}
})



})
}
});
4 changes: 4 additions & 0 deletions api/policies/addDataCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
module.exports = function addDataCreate(request, response, next) {
sails.log.verbose(__filename + ':' + __line + ' [Policy.addDataCreate() called]');

if(process.env.NO_AUTH === 'true') {
return next();
}

if (request.token) {
request.body.createdUser = request.token;
request.body.updatedUser = request.token;
Expand Down
2 changes: 1 addition & 1 deletion assets/js/app/connections/create-connection-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@
}
])
;
}());
}());
1 change: 1 addition & 0 deletions assets/js/app/core/layout/01_layout-controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
}, function (err) {
$scope.busy = false
UserModel.handleError($scope, err)
MessageService.error(_.get(err, 'data.message', 'Something went wrong...'))
}
);

Expand Down
29 changes: 21 additions & 8 deletions assets/js/app/dashboard/02_dashboard-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,20 +236,31 @@
$scope.checkingConnection = false;

// Finally, activate the node for the logged in user
UserModel
.update(UserService.user().id, {
node : created
})
.then(
if(window.no_auth) {
var credentials = $localStorage.credentials;
if(credentials.user.node && credentials.user.node.id == node.id) {
delete credentials.user.node;
}else{
credentials.user.node = created;
}
$rootScope.$broadcast('user.node.updated', credentials.user.node)
} else {
UserModel
.update(UserService.user().id, {
node : created
})
.then(
function onSuccess(res) {
var credentials = $localStorage.credentials
credentials.user.node = result.data[0]
$rootScope.$broadcast('user.node.updated',created)
},function(err){
$scope.busy = false
UserModel.handleError($scope,err)
MessageService.error(_.get(err, 'data.message', 'Something went wrong...'))
}
);
);
}

}).catch(function(error){
$log.debug("Check connection:error",error)
Expand All @@ -258,8 +269,10 @@
MessageService.error("Oh snap! Can't connect to the created node. Check your connections.")
})
},function(err){
$scope.busy = false
NodeModel.handleError($scope,err)
console.log(err);
$scope.busy = false
NodeModel.handleError($scope,err)
MessageService.error(_.get(err, 'data.message', 'Something went wrong...'))
}
)
;
Expand Down
Loading

0 comments on commit b012b08

Please sign in to comment.