从服务器端重定向到url。

时间:2022-11-22 20:02:00

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

我在调用login,在成功登录后,我想要显示仪表板屏幕。

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:

请帮助我重定向到仪表板URL:

Angular JS Code

角JS代码

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

节点。js代码

 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
}));

1 个解决方案

#1


0  

Answered here: Nodejs Redirect URL

在这里回答:Nodejs重定向URL。

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

或者你可以在你传递给的函数的前端使用$location。success。

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

$location的角文档:https://docs.angularjs.org/api/ng/service/$location。

#1


0  

Answered here: Nodejs Redirect URL

在这里回答:Nodejs重定向URL。

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

或者你可以在你传递给的函数的前端使用$location。success。

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

$location的角文档:https://docs.angularjs.org/api/ng/service/$location。