14
I am building a web app (with an API too) that is using Devise gem for authentication and I also use Doorkeeper gem for authentication for the API part.
Problem is now that when I go to the URL for receiving the Oauth2 code (and login) I am redirected to the web app and not the client callback URL.
What I need to do is redirect to the web app when signing in normally and to the callback URL when using Oauth.
How can I do this? I am overwriting the Devise sessions controller but I do not know what to put into it.
This is my code:
def new
session[:return_to] = params[:return_to] if params[:return_to]
resource = build_resource
clean_up_passwords(resource)
end
def create
resource = warden.authenticate!(auth_options)
sign_in(resource_name, resource)
if session[:return_to]
redirect_to session[:return_to]
session[:return_to] = nil
else
respond_with resource, :location => after_sign_in_path_for(resource)
end
end
Problem is that Devise seems to ignore my redirect logic.
Please advice further.