next step after the oauth authentication - sails

泪湿孤枕 提交于 2019-12-25 01:12:30

问题


I have followed this guide in my sails app and everyone seems to be working perfectly fine. when clicking the twitter button on localhost:1337/login page the website redirects the user to the authentication page. when the user accept the terms, the website redirect the user back to server homepage. here it ends, how can i use the twitter data that twiiter Apparently gave me?


回答1:


Once the user is authenticated in third-party service, he will be redirected back to your website together with his account information. You can access the profile details in your passport service:

/api/services/passport.js

passport.connect = function (req, query, profile, next) {

  var user = {
    firstName: profile.name.givenName,
    lastName: profile.name.familyName
  };

  // save passport, user, etc..
}

More details about profile variable: passportjs.org/guide/profile/



来源:https://stackoverflow.com/questions/26754236/next-step-after-the-oauth-authentication-sails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!