i am working with angular JS and REST API, i have two sign in pages one for admin and another sign in page for the users, sign in functionality for admin and users is working fine.. but when the user tires to sign in through the admin page.. authentication is performed and the user enters into the home page.. but users can access only the fields which are assigned for the user. how can i restrict users signing through the admin page??
this is the sign in function used in admin controller.js
$scope.signin = function() {
$http.post('/auth/signin', $scope.credentials).success(function(response) {
// If successful we assign the response to the global user model
$scope.authentication.user = response;
// And redirect to the index page
$location.path('/');
}).error(function(response) {
$scope.error = response.message;
});
};
server side sign in for both user and admin
/**
* Signin after passport authentication
*/
exports.signin = function(req, res, next) {
passport.authenticate('local', function(err, user, info) {
if (err || !user) {
res.status(400).send(info);
} else {
// Remove sensitive data before login
user.password = undefined;
user.salt = undefined;
req.login(user, function(err) {
if (err) {
res.status(400).send(err);
} else {
res.jsonp(user);
}
});
}
})(req, res, next);
};