{"action":"created","issue":{"url":"https://api.github.com/repos/meanjs/mean/issues/1284","repository_url":"https://api.github.com/repos/meanjs/mean","labels_url":"https://api.github.com/repos/meanjs/mean/issues/1284/labels{/name}","comments_url":"https://api.github.com/repos/meanjs/mean/issues/1284/comments","events_url":"https://api.github.com/repos/meanjs/mean/issues/1284/events","html_url":"https://github.com/meanjs/mean/issues/1284","id":144239084,"number":1284,"title":"Twitter login doesnt' redirect properly because passport.authenticate","user":{"login":"jorgeram","id":2403987,"avatar_url":"https://avatars.githubusercontent.com/u/2403987?v=3","gravatar_id":"","url":"https://api.github.com/users/jorgeram","html_url":"https://github.com/jorgeram","followers_url":"https://api.github.com/users/jorgeram/followers","following_url":"https://api.github.com/users/jorgeram/following{/other_user}","gists_url":"https://api.github.com/users/jorgeram/gists{/gist_id}","starred_url":"https://api.github.com/users/jorgeram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jorgeram/subscriptions","organizations_url":"https://api.github.com/users/jorgeram/orgs","repos_url":"https://api.github.com/users/jorgeram/repos","events_url":"https://api.github.com/users/jorgeram/events{/privacy}","received_events_url":"https://api.github.com/users/jorgeram/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2016-03-29T11:51:16Z","updated_at":"2016-04-04T20:42:24Z","closed_at":null,"body":"Hi. I'm getting a \"Page not found\" (Error: /api/auth/twitter/[object%20Object] is not a valid path.) after twitter authenticate with default project created by MEAN.JS 0.4.2 Yeoman generator.\r\n\r\nI'm pretty newbie but the problem seems to be that in users.authentication.server.controller.js -> oauthCallback -> line 122 we're redirecting to (redirectURL || sessionRedirectURL || '/') but passport.authenticate method give as an empty object in \"redirectURL\" so we're doing a redirect to \"object Object\" String (not a valid URL) instead of \"/\"\r\n\r\nLooking at passport.authenticate doc, they say that third parameter of custom callback is not a URL but \"an optional info argument containing additional details provided by the strategy's verify callback\" ([http://passportjs.org/docs/authenticate])\r\n\r\nI've tried with Facebook and is working fine because redirectURL is \"undefined\" and we're getting a redirect to \"/\".\r\n\r\nIt could need a change in MEAN.JS oauthCallback method, or maybe a passport problem?\r\n\r\nThanks in advance!\r\nRegards"},"comment":{"url":"https://api.github.com/repos/meanjs/mean/issues/comments/205485515","html_url":"https://github.com/meanjs/mean/issues/1284#issuecomment-205485515","issue_url":"https://api.github.com/repos/meanjs/mean/issues/1284","id":205485515,"user":{"login":"ChrisMaher","id":2607189,"avatar_url":"https://avatars.githubusercontent.com/u/2607189?v=3","gravatar_id":"","url":"https://api.github.com/users/ChrisMaher","html_url":"https://github.com/ChrisMaher","followers_url":"https://api.github.com/users/ChrisMaher/followers","following_url":"https://api.github.com/users/ChrisMaher/following{/other_user}","gists_url":"https://api.github.com/users/ChrisMaher/gists{/gist_id}","starred_url":"https://api.github.com/users/ChrisMaher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChrisMaher/subscriptions","organizations_url":"https://api.github.com/users/ChrisMaher/orgs","repos_url":"https://api.github.com/users/ChrisMaher/repos","events_url":"https://api.github.com/users/ChrisMaher/events{/privacy}","received_events_url":"https://api.github.com/users/ChrisMaher/received_events","type":"User","site_admin":false},"created_at":"2016-04-04T20:42:23Z","updated_at":"2016-04-04T20:42:23Z","body":"I was working on a 6 month old MEANjs 0.4 and got it all of a sudden on FB and Google Logins.\r\n\r\nI changed a server function to redirect to homepage instead of going back to the last page you clicked login from and it seemed to solve it.\r\n\r\nmodules/users/server/controllers/users/users.authentication.server.controller.js\r\n\r\n`/**\r\n * OAuth callback\r\n */\r\nexports.oauthCallback = function (strategy) {\r\n  return function (req, res, next) {\r\n    // Pop redirect URL from session\r\n    var sessionRedirectURL = req.session.redirect_to;\r\n    delete req.session.redirect_to;\r\n\r\n    passport.authenticate(strategy, function (err, user, redirectURL) {\r\n      if (err) {\r\n        return res.redirect('/authentication/signin?err=' + encodeURIComponent(errorHandler.getErrorMessage(err)));\r\n\r\n      }\r\n      if (!user) {\r\n        return res.redirect('/authentication/signin');\r\n      }\r\n      req.login(user, function (err) {\r\n        if (err) {\r\n          return res.redirect('/authentication/signin');\r\n        }\r\n\r\n        // return res.redirect(redirectURL || sessionRedirectURL || '/');\r\n        return res.redirect('http://www.mysite.com');\r\n\r\n      });\r\n    })(req, res, next);\r\n  };\r\n};`\r\n\r\nAlso another problem started and im not sure if its related but if you click login too quickly as the page is loaded it just refreshes and stary logged in. You have to wait at least 10 seconds before the logout button actually works."}}