0

I have an Ember CLI front-end app, and a Rails app using Devise for authentication. I thought I had things set up correctly, but I am running into a few problems.

1) After submitting the login form, I do not get re-directed. If I manually click a link that is behind authentication, it sees I'm authenticated.

2) After reloading the page, the session info in local storage doesn't persist.

Any ideas?

Thanks in advance

yeabuddy
  • 11
  • 2

2 Answers2

0

1) it by defaults redirect to index route after login, stick a debugger in the beforeModel hook of the index route and verify this

2) something like this in your config/environment.js, but since your using the devise plugin and not your own custom authorizer not 100% sure

ENV['simple-auth'] = {
  localStorageKey: 'my-app-session',
  store: 'simple-auth-session-store:local-storage',
  authorizer: 'authorizer:devise'
};

it's sort of vague questions though, need more code and info if your using tokens or cookies, etc?

flylib
  • 1,128
  • 2
  • 10
  • 17
  • Hi Flylib, Sorry, I knew I probably should have provided more info but wasn't sure what would be relevant. It looks like it was a rails-csrf library thing. Removing that fixed it. I still lose the session though when I reload the page. It doesn't persist in local storage. – yeabuddy Feb 05 '15 at 02:30
  • Happens in Chrome, Safari, and Firefox. This is the contents of local storage after logging in: {"authenticator":"simple-auth-authenticator:devise","sessions":[["trainer_token","FZHxDS_CB-VN1uc74NNo"],["trainer_email”,”**********@gmail.com"]]} – yeabuddy Feb 05 '15 at 03:06
  • try sticking that code above in your environment/config.js if your using ember-cli – flylib Feb 05 '15 at 03:09
  • try this ENV['simple-auth-devise'] = { resourceName: 'trainer' }; – flylib Feb 05 '15 at 04:20
  • your issue seems to be you have trainer as the key instead of user, read here http://stackoverflow.com/questions/25215010/ember-simple-auth-session-lost-on-refresh and here https://github.com/simplabs/ember-simple-auth/tree/master/packages/ember-simple-auth-devise#server-side-setup – flylib Feb 05 '15 at 04:21
  • Ahhh I figured it out. It looks like because I am using activemodel serializers in my rails app, it was including the root(in this case sessions: because the response was being served from sessions controller). I told it to not use ActiveModel Serializers, render json: data, status: 201, serializer: nil That did the trick! Thanks for the help! – yeabuddy Feb 05 '15 at 04:48
0

Ahhh I figured it out. It looks like because I am using activemodel serializers in my rails app, it was including the root(in this case sessions: because the response was being served from sessions controller). I told it to not use ActiveModel Serializers, render json: data, status: 201, serializer: nil That did the trick! I'm guessing AMS and custom resource names do not play well together.

yeabuddy
  • 11
  • 2