import AdaptiveStore from 'ember-simple-auth/session-stores/adaptive';

Session store that persists data in the browser's localStorage (see LocalStorageStore) if that is available or in a cookie (see CookieStore) if it is not.

This is the default store that Ember Simple Auth will use when the application doesn't define a custom store.

This session store does not work with FastBoot. In order to use Ember Simple Auth with FastBoot, configure the CookieStore as the application's session store.

Methods

source public

clear( ) Ember.RSVP.Promise

Overrides: clear of BaseStore.

Clears the store by deleting the key from localStorage if that is available or by deleting the cookie if it is not.

Returns

Ember.RSVP.Promise

A promise that resolves when the store has been cleared successfully and rejects otherwise.

source public

persist(data) Ember.RSVP.Promise

Overrides: persist of BaseStore.

Persists the data in the localStorage if it is available or in a cookie if it is not.

Arguments

data: Object

The data to persist

Returns

Ember.RSVP.Promise

A promise that resolves when the data has successfully been persisted and rejects otherwise.

source public

restore( ) Ember.RSVP.Promise

Overrides: restore of BaseStore.

Returns all data currently stored in the localStorage if that is available - or if it is not, in the cookie - as a plain object.

Returns

Ember.RSVP.Promise

A promise that resolves with the data currently persisted in the store when the data has been restored successfully and rejects otherwise.

Properties

source public

cookieDomain: String

Default: null

The domain to use for the cookie if localStorage is not available, e.g., "example.com", ".example.com" (which includes all subdomains) or "subdomain.example.com". If not explicitly set, the cookie domain defaults to the domain the session was authenticated on.

source public

cookieExpirationTime: Integer

Default: null

The expiration time for the cookie in seconds if localStorage is not available. A value of null will make the cookie a session cookie that expires and gets deleted when the browser is closed.

source public

cookieName: String

Default: ember_simple_auth-session

The name of the cookie to use if localStorage is not available.

source public

cookiePath: String

Default: '/'

The path to use for the cookie, e.g., "/", "/something".

source public

localStorageKey: String

Default: 'ember_simple_auth-session'

The localStorage key the store persists data in if localStorage is available.

source public

sameSite: String

Default: null

Allows servers to assert that a cookie ought not to be sent along with cross-site requests, which provides some protection against cross-site request forgery attacks (CSRF).

Available options:

  • "Strict"
  • "Lax"

Events

source

sessionDataUpdated

Inherited from: sessionDataUpdated of BaseStore.

Triggered when the session store's data changes due to an external event, e.g., from another tab or window of the same application. The session handles that event, passes the updated data to its authenticator's {{#crossLink "BaseAuthenticator/restore:method"}}{{/crossLink}} method and handles the result of that invocation accordingly.

Arguments

data: Object
The updated session data