链接在身份validation和聚合数据中
我正在使用Ruby on Rails构建一个Web应用程序,我希望我的用户对来自Linked In(以及其他像Github,Twitter等等)的数据进行身份validation和聚合。
我正在使用这些gem:
- 设计注册
- omniauth-linkedin用于身份validation
- pengwynn / linkedin用于数据聚合
虽然,Linked In有一个不太好的pin东西。 有没有办法避免它,并从我的用户帐户获取我想要的数据,而无需他们去链接,获取一个引脚并提交给我?
提前致谢。
authentications_controller.rb
class AuthenticationsController < ApplicationController def index @authentications = current_user.authentications if current_user end def create omniauth = request.env["omniauth.auth"] authentication = Authentication. find_by_provider_and_uid(omniauth['provider'], omniauth['uid']) if authentication flash[:notice] = "Signed in successfully." sign_in_and_redirect(:user, authentication.user) elsif current_user current_user.authentications. create!(provider: omniauth['provider'], uid: omniauth['uid']) current_user.apply_omniauth(omniauth) flash[:notice] = "Authentication successful." redirect_to authentications_url else user = User.new user.apply_omniauth(omniauth) if user.save flash[:notice] = "Signed in successfully." sign_in(:user, user) redirect_to user_path(user.username) else session[:omniauth] = omniauth.except('extra') redirect_to new_user_registration_url end end end