简体   繁体   中英

Redirect to a url from server-side

I am calling login, after successfull login, I would like to show dashboard screen.

But, dashboard page is not displaying after successful login. page is not refreshing, login page remains. No change.

Please help me to redirect to dashboard URL:

Angular JS Code

function loginctrl($scope, $http) {
$scope.login = function() {
    emp_url = '/login';
    emp_msg = "SUCCESSFULLY SIGN Up";

    $http.post(emp_url, $scope.formData).success(function(data) {                       
    });
};

}

Node.js Code

 app.get('/dashboard', isLoggedIn, function(req, res){  
    res.sendfile('./public/template-home.html', {user : req.user});     
});

app.post('/login', passport.authenticate('local-login', {
    successRedirect : '/dashboard', // redirect to the secure dashboard section
    failureRedirect : '/login', // redirect back to the signup page if there is an error
    failureFlash : true // allow flash messages
}));

Answered here: Nodejs Redirect URL

Or you can use $location on the front end in the function you pass to .success

Angular docs for $location: https://docs.angularjs.org/api/ng/service/$location

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM