{"action":"created","issue":{"url":"https://api.github.com/repos/ParsePlatform/parse-server/issues/497","repository_url":"https://api.github.com/repos/ParsePlatform/parse-server","labels_url":"https://api.github.com/repos/ParsePlatform/parse-server/issues/497/labels{/name}","comments_url":"https://api.github.com/repos/ParsePlatform/parse-server/issues/497/comments","events_url":"https://api.github.com/repos/ParsePlatform/parse-server/issues/497/events","html_url":"https://github.com/ParsePlatform/parse-server/issues/497","id":134756200,"number":497,"title":"server-side login (replacing parse-express-cookie-session)","user":{"login":"mchun","id":7677094,"avatar_url":"https://avatars.githubusercontent.com/u/7677094?v=3","gravatar_id":"","url":"https://api.github.com/users/mchun","html_url":"https://github.com/mchun","followers_url":"https://api.github.com/users/mchun/followers","following_url":"https://api.github.com/users/mchun/following{/other_user}","gists_url":"https://api.github.com/users/mchun/gists{/gist_id}","starred_url":"https://api.github.com/users/mchun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mchun/subscriptions","organizations_url":"https://api.github.com/users/mchun/orgs","repos_url":"https://api.github.com/users/mchun/repos","events_url":"https://api.github.com/users/mchun/events{/privacy}","received_events_url":"https://api.github.com/users/mchun/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":19,"created_at":"2016-02-19T02:43:05Z","updated_at":"2016-07-23T20:28:49Z","closed_at":"2016-02-22T01:17:14Z","body":"My app was relying on 'parse-express-cookie-session' offered by Parse to do server-side login, i.e.:\r\n\r\n```\r\n  app.post('/login', function(req, res) {\r\n    Parse.User.logIn(req.body.username, req.body.password).then(function(user) {\r\n      res.redirect('/');\r\n    }, function(error) {\r\n      res.render('login', { flash: error.message });\r\n    });\r\n  });\r\n\r\n  app.post('/logout', function(req, res) {\r\n    Parse.User.logOut();\r\n    res.redirect('/');\r\n  });\r\n```\r\n\r\nI used Parse.User.Current() to check if the user is logged in on server-side.\r\n\r\nNow, I replaced the 'parse-express-cookie-session' by 'express-session'. And do the login/logout in this way:\r\n\r\n```\r\n  app.post('/login', function(req, res) {\r\n    Parse.User.logIn(req.body.username, req.body.password).then(function(user) {\r\n      req.session.user=user;\r\n      res.redirect('/');\r\n    }, function(error) {\r\n      res.render('login', { flash: error.message });\r\n    });\r\n  });\r\n\r\n  app.post('/logout', function(req, res) {\r\n    req.session.user = null;\r\n    res.redirect('/');\r\n  });\r\n```\r\n\r\nI then see if the user is logged in by checking req.session.user = null . But I cannot access it inside cloudcode.\r\nPerhaps 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? \r\nIt 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. "},"comment":{"url":"https://api.github.com/repos/ParsePlatform/parse-server/issues/comments/234738443","html_url":"https://github.com/ParsePlatform/parse-server/issues/497#issuecomment-234738443","issue_url":"https://api.github.com/repos/ParsePlatform/parse-server/issues/497","id":234738443,"user":{"login":"woodardj","id":557897,"avatar_url":"https://avatars.githubusercontent.com/u/557897?v=3","gravatar_id":"","url":"https://api.github.com/users/woodardj","html_url":"https://github.com/woodardj","followers_url":"https://api.github.com/users/woodardj/followers","following_url":"https://api.github.com/users/woodardj/following{/other_user}","gists_url":"https://api.github.com/users/woodardj/gists{/gist_id}","starred_url":"https://api.github.com/users/woodardj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/woodardj/subscriptions","organizations_url":"https://api.github.com/users/woodardj/orgs","repos_url":"https://api.github.com/users/woodardj/repos","events_url":"https://api.github.com/users/woodardj/events{/privacy}","received_events_url":"https://api.github.com/users/woodardj/received_events","type":"User","site_admin":false},"created_at":"2016-07-23T20:28:49Z","updated_at":"2016-07-23T20:28:49Z","body":"Thanks @mchun! I ended up piecing the methodology into an authenticating middleware we already had, but this was super useful as a starting point. I am curious though, we had good luck querying `_Session` with the JS/Express SDK directly instead of going to the REST endpoint, is there a reason you went that route?"}}
{"actor":{"display_login":"woodardj"}}