Reputation: 1665
Using Devise Gem in my project and does anybody know how to redirect user to specific url only if user signed in with token?
Upvotes: 0
Views: 162
Reputation: 1936
If i am getting your question right so you are asking that how to redirect user after he/she sign's in.
So i ve tried this in my project
Here is the code
def after_sign_in_path_for(resource)
# Use the route you want here (i have given the url like this: '/show')
end
Hope i am taking the right meaning of the question.!! :)
Upvotes: 0
Reputation: 540
You can do this by creating a your own SessionsController which you can find on git
like this:
# POST /resource/sign_in
class SessionsController < Devise::SessionsController
def create
self.resource = warden.authenticate!(auth_options)
set_flash_message(:notice, :signed_in) if is_navigational_format?
sign_in(resource_name, resource)
#here you can enter your specific token code
# I guess you would do it with something like:
# if session[:token] = XYZ
# respond with ...
# else
# respond_with resource, :location => after_sign_in_path_for(resource)
# end
end
end
for using this controller you also have to change your config/routes.rb
devise_for :users, :controllers => {:sessions => "sessions"}
hope it helps you :)
Upvotes: 1