import ToriiAuthenticator from 'ember-simple-auth/authenticators/torii';

Authenticator that wraps the Torii library and thus allows to connect any external authentication provider that torii defines a provider for.

In order to use this authenticator, the application needs to have the torii addon installed and must inject the torii service into the authenticator:

// app/authenticators/torii.js
          import ToriiAuthenticator from 'ember-simple-auth/authenticators/torii';
          
          export default ToriiAuthenticator.extend({
            torii: Ember.inject.service()
          });
          

Methods

source public

authenticate(provider, options) Ember.RSVP.Promise

Overrides: authenticate of BaseAuthenticator.

Authenticates the session by opening the specified torii provider. For more documentation on torii and its providers abstraction, see the project's README, specifically the section on providers.

Arguments

provider: String

The torii provider to authenticate the session with

options: Object

The options to pass to the torii provider

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.

Closes the torii provider. If the provider is successfully closed, this method returns a resolving promise, otherwise it will return a rejecting promise, thus intercepting session invalidation.

Returns

Ember.RSVP.Promise

A promise that when it resolves results in the session being invalidated

source public

restore(data) Ember.RSVP.Promise

Overrides: restore of BaseAuthenticator.

Restores the session by calling the torii provider's fetch method.

Many torii providers do not implement the fetch method. If the provider in use does not implement the method simply add it as follows:

// app/torii-providers/facebook.js
                          import FacebookOauth2Provider from 'torii/providers/facebook-oauth2';
                          
                          export default FacebookOauth2Provider.extend({
                            fetch(data) {
                              return data;
                            }
                          });
                          

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

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