Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to current_user inside of rails-api #85

Closed
nickskalkin opened this issue Jan 27, 2016 · 2 comments
Closed

Access to current_user inside of rails-api #85

nickskalkin opened this issue Jan 27, 2016 · 2 comments

Comments

@nickskalkin
Copy link

Hello everyone! I'm totally newbie in AngularJS. I try to set up authentication using your library, and I've stuck in one point. I use rails-api as a backend. When trying to achieve current_user inside of it, I have 401 Unauthorized error. I don't know what it could be, so I've try to compare pure working RoR/Devise (without json api) request, with my own (not working). Seems like I have no valid cookie.
Working example sends something like:
Cookie: _notes_session=RVo2cUo4SXRNblMrYnFZdURlV09pSUFFdEMvOHIvSTEwZjNjaXQ5NnlkYlhId3ZEYkpIaXJWdHJOaDFUUTRjYTcrdTJ5cDNId2paKzNlQUlPU05XMzBiTDlVTFR5TXpNdE1yc0RlNjJFeCtqQTNSclZVbHVTMmwzZWpUNER3c25zTllqaElrb0h1SCtKNnFhSFBST0F1TlpCWm0xbC9Qc0dMakxiZGtwY0NiS2pTeTRCZWw5SE5jRE5sTElRaGNTY1VreVI2dW5RUExUV0plYnZ5Ym9PblMzMDRUQlBmTEZVOWkxcktTVHdYOE5vN2hXaDNTVFhJUmEvN1NNMGRKTkh0TEFNSTN1by9mQTgyNzZ0VUdJb2Q1QTBMWlFRem1QSmRzcy9pcFNkOW5ZcmFiUFQ0Z3pZRjg1YzZKZzlQdXktLVZQUURqWmZYa2VDaXc1WWQ0RjgwZUE9PQ%3D%3D--f58ab59c39ff22799c3e577ae52b92765ce7d249

The question is: Do I really need that cookie to be authorized in my rails-api app, and when can I get this cookie.

@nickskalkin
Copy link
Author

Sorry, it was on rails-api side. Rails-api by default doesn't use ActionDispatch::Cookies and ActionDispatch::Session::CookieStore. You can prevent it by setting config.api_only = false in your application.rb.

@nickskalkin
Copy link
Author

But I suppose it's not a good practice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant