import DeviseAuthenticator from 'ember-simple-auth/authenticators/devise';

Authenticator that works with the Ruby gem devise.

As token authentication is not actually part of devise anymore, the server needs to implement some customizations to work with this authenticator - see this gist.

Methods

source public

authenticate(identification, password) Ember.RSVP.Promise

Overrides: authenticate of BaseAuthenticator.

Authenticates the session with the specified identification and password; the credentials are POSTed to the server. If the credentials are valid the server will responds with a token and identification. If the credentials are valid and authentication succeeds, a promise that resolves with the server's response is returned, otherwise a promise that rejects with the server error is returned.

Arguments

identification: String

The user's identification

password: String

The user's password

Returns

Ember.RSVP.Promise

A promise that when it resolves results in the session becoming authenticated

source public

invalidate( ) Ember.RSVP.Promise

Overrides: invalidate of BaseAuthenticator.

Does nothing

Returns

Ember.RSVP.Promise

A resolving promise

source protected

makeRequest(data, options) Promise

Makes a request to the devise server.

Arguments

data: Object

The request data

options: Object

request options that are passed to fetch

Returns

Promise

The promise returned by fetch

source public

restore(data) Ember.RSVP.Promise

Overrides: restore of BaseAuthenticator.

Restores the session from a session data object; returns a resolving promise when there are non-empty token and identification values in data and a rejecting promise otherwise.

Arguments

data: Object

The data to restore the session from

Returns

Ember.RSVP.Promise

A promise that when it resolves results in the session becoming or remaining authenticated

Properties

source public

identificationAttributeName: String

Default: 'email'

The identification attribute name. This will be used in the request and also be expected in the server's response.

source public

rejectWithResponse: Boolean

Default: false

When authentication fails, the rejection callback is provided with the whole fetch response object instead of it's response JSON or text.

This is useful for cases when the backend provides additional context not available in the response body.

source public

rejectWithXhr: Boolean

Deprecated:Use rejectWithResponse instead

Default: false

When authentication fails, the rejection callback is provided with the whole XHR object instead of it's response JSON or text.

This is useful for cases when the backend provides additional context not available in the response body.

source public

resourceName: String

Default: 'user'

The devise resource name. This will be used in the request and also be expected in the server's response.

source public

serverTokenEndpoint: String

Default: '/users/sign_in'

The endpoint on the server that the authentication request is sent to.

source public

tokenAttributeName: String

Default: 'token'

The token attribute name. This will be used in the request and also be expected in the server's response.

Events

source

sessionDataInvalidated

Inherited from: sessionDataInvalidated of BaseAuthenticator.

Triggered when the authenciation data is invalidated by the authenticator due to an external or scheduled event. This might happen e.g. if a token expires or an event is triggered from an external authentication provider that the authenticator uses. The session handles that event and will invalidate itself when it is triggered.

source

sessionDataUpdated

Inherited from: sessionDataUpdated of BaseAuthenticator.

Triggered when the authentication data is updated by the authenticator due to an external or scheduled event. This might happen e.g. if the authenticator refreshes an expired token or an event is triggered from an external authentication provider that the authenticator uses. The session handles that event, passes the updated data back to the authenticator's restore method and handles the result of that invocation accordingly.

Arguments

data: Object

The updated session data