ile nodejs çalışmıyor ama bu verileri güncelleştirmeye çalıştığınızda, banaGüncelleme çerez ben girişten sonra bir oturum açma çerez oluşturduk
Can't set headers after they are sent.
Benim kod aşağıda bir hata verir.
/* Logout to main user. */ /* Not Working */
router.get('/logoutToMain', mustBe.authorized('supportuser'), function (req, res) {
var loginSealed = req.cookies[req.ApplicationCookies.LoginCookie];
if (loginSealed != undefined) {
iron.unseal(loginSealed, req.Security.CookiePassword, iron.defaults, function (err, unsealed) {
if (!err) {
unsealed.SupportUser = null;
iron.seal(unsealed, req.Security.CookiePassword, iron.defaults, function (err, sealed) {
if (!err) {
res.cookie(req.ApplicationCookies.LoginCookie, sealed, { expires: new Date(Date.now() + 432000), httpOnly: true, ephemeral: true });
}
});
//res.cookie(req.ApplicationCookies.LoginCookie, unsealed, { expires: new Date(Date.now() - 1000), httpOnly: true });
}
});
}
res.redirect('/');
});
Bu çerezi kaldırdığımda, bu işe yarar. (Kod aşağıda) kod parçasının altında
/* Logout action. */ /* Working */
router.get('/logout', mustBe.authenticated(), function (req, res) {
var LoginCookie = req.cookies[req.ApplicationCookies.LoginCookie];
if (LoginCookie != undefined) {
res.cookie(req.ApplicationCookies.LoginCookie, null, { expires: new Date(Date.now() - 1000), httpOnly: true });
}
res.redirect('/');
});
için çerez yaratıyor node.js zaman uyumsuz davranış hakkında kullanıcıya
var LoggedinEmployee = {
EmployeeID : recordset[0][0].EmployeeId,
EmployerID : recordset[0][0].EmployerId,
EmployerName : recordset[0][0].EmployerName,
AccountName : Employer.AccountName,
EmpLevel : recordset[0][0].EmpLevel,
EmployeeName : recordset[0][0].EmployeeName,
CorpId: recordset[0][0].CorpID,
Login: user.Login,
Password: user.Password,
SupportUser: null
};
iron.seal(LoggedinEmployee, req.Security.CookiePassword, iron.defaults, function (err, sealed) {
if (!err) {
res.cookie(req.ApplicationCookies.LoginCookie, sealed, { expires: new Date(Date.now() + 432000), httpOnly: true, ephemeral: true });
req.ActionOutput.Status = req.ActionStatus.Success;
req.ActionOutput.Message = 'Logged In. Redirecting to dashboard...';
res.send(JSON.stringify(req.ActionOutput));
} else {
req.ActionOutput.Status = req.ActionStatus.Error;
req.ActionOutput.Message = 'System Error';
res.send(JSON.stringify(req.ActionOutput));
}
});
https://www.youtube.com/watch?v=l9orbM1MJNk –
Teşekkürler @Nikhil, nodejs .net, java gibi eşzamansız modda çalışmayı unuttum. Aptal hata kodunda yapıldı: D –
Bu hata, yeni node.js devs tarafından çok kez tekrarlanır :) –