我正在使用MeanJS堆栈来开发Web应用程序.我遇到的问题是,我的常规注册过程有一些Oauth用户配置文件不常见的独特参数.因此,当我让用户去注册Facebook时,我将它们移动到一个新的注册表单,让他们填写额外的参数,然后点击"注册Facebook".
这些路由与此处的常见MeanJS路由相同:https: //github.com/meanjs/mean/blob/master/app/routes/users.server.routes.js
特别是这些线:
app.route('/auth/facebook').get(passport.authenticate('facebook', {
scope: ['email']
}));
app.route('/auth/facebook/callback').get(users.oauthCallback('facebook'));
Run Code Online (Sandbox Code Playgroud)
我想做的是,将额外的参数附加到请求对象,以便当auth进程到达exports.saveOAuthUserProfile内部时:https://github.com/meanjs/mean/blob/master/app/controllers/users /users.authentication.server.controller.js
此函数将能够访问这些参数并将其保存为用户模型的一部分.
我已经尝试将参数附加到Get请求和访问
req.params.paramId
但这不起作用,因为你不能用facebook api注册一个param加载的请求(或者至少看起来就是这样).
我已经在StackOverflow的其他地方读过你可以加载请求状态,但这对我来说似乎很奇怪.这是以下链接:Facebook OAuth:自定义callback_uri参数
所以,关于如何将额外数据加载到Oauth请求的任何指导,以便当我保存用户配置文件时我可以访问并保存它,这将是很好的.
多谢你们.
我将其发布为其他遇到相同问题的人的参考。
$ rake
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)
/home/travis/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in `eval'
/home/travis/.rvm/gems/ruby-1.9.3-p551/bin/ruby_executable_hooks:15:in `<main>'
(See full trace by running task with --trace)
The command "rake" exited with 1.
Run Code Online (Sandbox Code Playgroud)
在Travis-CI上构建Node.JS项目时,将输出以上内容。.travis.yml文件有效:
language: node_js
node_js:
- "0.12"
Run Code Online (Sandbox Code Playgroud)