-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Description
My app was relying on 'parse-express-cookie-session' offered by Parse to do server-side login, i.e.:
app.post('/login', function(req, res) {
Parse.User.logIn(req.body.username, req.body.password).then(function(user) {
res.redirect('/');
}, function(error) {
res.render('login', { flash: error.message });
});
});
app.post('/logout', function(req, res) {
Parse.User.logOut();
res.redirect('/');
});
I used Parse.User.Current() to check if the user is logged in on server-side.
Now, I replaced the 'parse-express-cookie-session' by 'express-session'. And do the login/logout in this way:
app.post('/login', function(req, res) {
Parse.User.logIn(req.body.username, req.body.password).then(function(user) {
req.session.user=user;
res.redirect('/');
}, function(error) {
res.render('login', { flash: error.message });
});
});
app.post('/logout', function(req, res) {
req.session.user = null;
res.redirect('/');
});
I then see if the user is logged in by checking req.session.user = null . But I cannot access it inside cloudcode.
Perhaps this is not a right way to do(?) as it is recommended to use req.user, but I have no idea how to make it work, req.user is always null. Any help from you guys?
It would be great to even have a small sample app offered by Parse showing simple server-side login like Anyimg as there should be similar cases around like me.
Metadata
Metadata
Assignees
Labels
No labels