User Resilience Ember Auth

So, I have an ember-rails application configured using the authentication API, and I can successfully (or not) authenticate using ember auth, and everything works. However, authentication is retained only during the current application session. If I reload the page or enter the URL, I must re-authenticate.

Are there any settings or settings necessary for the authorization token to be longer? I'm not necessarily talking about Remember Me functionality, as it makes the session a little more complicated.

My base code is:

Auth Object:

App.Auth = Em.Auth.create currentUser: null signInEndPoint: '/users/sign_in' signOutEndPoint: '/users/sign_out' tokenKey: 'auth_token' tokenIdKey: 'user_id' 

Login:

 App.AuthSignInView = Ember.View.extend templateName: 'auth/sign_in' email: null password: null submit: (event, view) -> event.preventDefault() event.stopPropagation() StripfighterEmber.Auth.signIn data: email: @get 'email' password: @get 'password' 

Auth Template:

 <form class="form-inline"> {{view Ember.TextField class="input-small" placeholder="Email" valueBinding="view.email"}} {{view Ember.TextField type="password" class="input-small" placeholder="Password" valueBinding="view.password"}} <button type="submit" class="btn btn-inverse btn-small">Sign in</button> </form> 
+4
source share
2 answers

ember-auth dev is here.

Your use case is essentially the default “remember me”, but with a very short duration. You can still enable rememberable (with auto recovery) and just "quietly enter" this function, i.e. Make your server return the saved cookie while the mark is valid.

The reason for this is that, from the point of view of the virtual application, there is no difference between restarting the browser, changing the URL and updating. All this represents a restart of the application. From this it follows that ember must restore the state of the application from the stored information (cookies, localStorage) and pass the information (url). An authentication session is no different. The rememberable module saves the authentication token in the first (you choose, cookie or localStorage ); The urlAuthenticatable module allows urlAuthenticatable to pass authentication information to a URL.

As Mike said, you can also use your own, but I would advise you to take advantage of existing features (“other people's efforts”).

+2
source

Are there any settings or settings necessary for the authorization token to be longer? I'm not necessarily talking about Remember Me functionality, as it makes the session a little more complicated.

You can save the authentication token to a cookie or local storage. but I would not recommend it. This is what the built-in ember-auth function has for me. http://ember-auth.herokuapp.com/docs

+2
source

Source: https://habr.com/ru/post/1489987/


All Articles