ruby on rails - Which one is better ? Omniauth or Omniauth+Devise for twitter verification? -
if use omniauth twitter verification.. code following is
def create user = user.from_omniauth(env["omniauth.auth"]) session[:user_id] = user.id redirect_to root_url, notice: "successfully signed in" end but if use omniauth+devise twitter verificaiton.. code following is
def twitter omni= request.env["omniauth.auth"] authentication = authentication.find_by_provider_and_uid(omni['provider'],omni['uid']) if authentication flash[:notice]="logged in successfully" sign_in_and_redirect user.find(authentication.user_id) elsif current_user token=omni['credentials'].token token_secret=omni['credentials'].secret current_user.authentications.create! (:provider=>omni['provider'],:uid=>omni['uid'],:token=>token,:token_secret=>token_secret) flash[:notice]="authentication successful." sign_in_and_redirect current_user else user=user.new user.apply_omniauth(omni) if user.save flash[:notice]="logged in." sign_in_and_redirect user.find(user.id) else session[:omniauth]=omni.except('extra') redirect_to new_user_registration_path end end end which 1 better omniauth or omniauth+devise?
devise give ready made helper functions current_user, user_signed_in? , controller filters before :authenticate_user!.
though basic implement on our own, when omniauth-twitter alone, have implement on own.
if don't plan have sophisticated user authentication , want simple twitter based authentication, can go ahead , use omniauth-twitter alone. devise open application mannual (form based) registrations default, may not want.
Comments
Post a Comment