나는 노드를 배우고있다. 나는 단순히 json을 사용하여 사용자가 로그인 할 수있게 해주는 아주 기본적인 앱을 만들려고 노력하고있다. 그런 다음 로그 아웃 할 때까지 세션을 유지합니다.Passport.js 세션 혼동
Auth.logout()
을 그리고 당신이 있는지 확인해야하는 경우 : asp.net이 방금 설정에서 설정하고 부르는 doddle ...가 로그 아웃 할 때
Auth.Login(username,pasword)
방금 할 수있다 그들은 단순히 당신이 로그인 :
Auth.IsLoggedIn()
또는 그 코드. 노드에 대한 Passport가 그렇게 단순하지 않은 것 같습니다. 나는이 작업을 얻는 모든 밤을 보냈다 ...
app.post('/authentication/login', function handleLocalAuthentication(req, res, next) {
passport.authenticate('local', function(err, user, info) {
// Manually establish the session...
req.login({username:'[email protected]',password:'password'}, function(err) {
if (err) return next(err);
return res.json({
message: 'user authenticated'
});
});
})(req, res, next);
});
app.get('/authentication/isauthenticated',function(req,res){
console.log(req.isAuthenticated());
})
passport.use(new LocalStrategy(
function(username, password, done) {
return done(null, {username:'ss',password:'sffds'});
}
));
그래서 지금은 어떤 쿠키가없는, 아무 세션은 내가 로그인 할 때 지속되지 다음
/authentication/isAuthenticated
URL을 기록했다. 나는 전략에서 멈추는 중단 점을 얻을조차 수 없다. ...
나는 이것을 위해 틀린 해결책을보고있다? 기본 미들웨어 기능으로 내 자신의 인증 또는 무언가를 롤업해야합니까?
감사합니다. 정말 도움이되었습니다. – Exitos
나는 행복했다. 감사합니다 – thyforhtian
@thyforhtian "이 튜토리얼"에 대한 링크가 깨진 것 같습니다 – peralmq