A
A
Alexey Aristov2016-06-30 17:00:31
JavaScript
Alexey Aristov, 2016-06-30 17:00:31

Ember Simple Auth: what to do with the key received during authentication?

Installed ember simple auth, created a web form and a custom authentificator.
When the form is submitted, an action is executed, inside which the overridden method authenticate authenticator-a is called. From the authenticate method, a request is sent to the server and a token is returned in response.
Where should this token be stored? How to save it?
How can I make the token be sent on all further requests?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Aristov, 2016-06-30
@aristov

Found this option:

Ember.$.ajaxSetup({
                  headers: {
                      'Authorization': 'Bearer ' + responseObject.token
                  }
              });

----------------------------
It seems that queries to the database should be performed through the default adapter, which must be located in app/adapters/application. js. Apparently, in this default adapter, you need to save the authorization key.

S
Stanislav Romanov, 2016-07-03
@Kaer_Morchen

Where should this token be stored?

ember-simple-auth has a special layer that stores session data. The token can be stored either in LocalStorage or in Cookie or in memory , but then the user will have to log in every time the session is terminated.
You can use any built-in store, or write your own by extending BaseStore , there are only three methods: clear, persist, restore.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question