You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am developing a store as a separate app to be integrated with my another app via APIs. I have used doorkeeper as OAuth2 provider. The code below is from the Oauth callback which is called when user is successfully validated by OAuth2 provider base-app.
in line sign_in_and_redirect @user, :event => :authentication I intend to signin with the validated user and redirect. The Login button in home page was still visible.
While moving to the code base I found that it checks if spree_current_user is present or not.
<% if spree_current_user %><li><%=link_toSpree.t(:my_account),spree.account_path%></li><li><%=link_toSpree.t(:logout),spree.logout_path%></li><%else%><liid="link-to-login"><%=link_toSpree.t(:login),spree.login_path%></li><%end%>
But the sign_in_and_redirect is supposed to set the spree_current_user but it was not.
How can I let users signin and also set spree_current_user so that my users signed in via SSO no more see the Login button even after logged in.
Thanks :)
Code sample
classUsers::OmniauthCallbacksController < Devise::OmniauthCallbacksControllerdefthe_pact# You need to implement the method below in your model (e.g. app/models/user.rb)@user=Spree::User.from_omniauth(request.env["omniauth.auth"])if@user.persisted?sign_in_and_redirect@user,:event=>:authentication#this will throw if @user is not activatedset_flash_message(:notice,:success,:kind=>"ThePact")ifis_navigational_format?elsesession["devise.the_pact_data"]=request.env["omniauth.auth"]redirect_tonew_user_registration_urlendenddeffailureredirect_toroot_pathendend
classApplicationController < ActionController::Base# Prevent CSRF attacks by raising an exception.# For APIs, you may want to use :null_session instead.protect_from_forgerywith: :exceptiondefspree_current_usercurrent_userendend
Problem
I am developing a store as a separate app to be integrated with my another app via APIs. I have used
doorkeeper
as OAuth2 provider. The code below is from the Oauth callback which is called when user is successfully validated by OAuth2 provider base-app.in line
sign_in_and_redirect @user, :event => :authentication
I intend to signin with the validated user and redirect. TheLogin
button in home page was still visible.While moving to the code base I found that it checks if
spree_current_user
is present or not.But the
sign_in_and_redirect
is supposed to set thespree_current_user
but it was not.After prying I found
Question:
How can I let users signin and also set
spree_current_user
so that my users signed in viaSSO
no more see theLogin
button even after logged in.Thanks :)
Code sample
Libraries used:
The text was updated successfully, but these errors were encountered: