Search code examples
ajaxauthenticationcookiestokenember-simple-auth

How to set and get values from cookie in EmberJS using ember-simple-auth


Excuse my naivety, but I am new to sessions, cookie based authentication and Python Tornado. I am trying to access an API written in python Tornado, and am using Ember CLI for the client. I can't seem to set cookie values in the request sent to the server. How does one set the cookie correctly in AJAX/Ember.JS?

Techs I'm using:

  • Ember CLI
  • Ember Simple Auth
  • Python Tornado

My situation

  1. What I have: A log in page where users can try to log in.

  2. What I need: A way to set parts of the successful response from the server into a local storage location, or cookie.

  3. What I have: An API endpoint that I am accessing using AJAX

  4. What I need: A way to pass parts of the log-in response data as a 'cookie' as the server is throwing an error saying that the cookie is invalid or missing.


Solution

  • Ok so whomever is running into the same problem, I basically had to set the following ajax setting in my "findAll" function for my model, and on just the authenticate method.

    ...
    xhrFields: {
        withCredentials: true
    },
    success: succsFunction, 
    error: errorFunction...