An Ember Ecosystem
For Spree Commerce

spree-ember-auth

Extends Ember.Mixin

A mixin for providing utility methods to routes associated with User behaviour. These are grouped together in the case the ambitious developers want to glob this behaviour together into a single route, for a highly interactive experience.

Important: The spree-ember-auth install generator will attempt to overwrite your application route. If you opt out of this, or you're defining it in a pod instead, you'll need to ensure that you're mixing Simple Auth's Application Route Mixin into your application route.

import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin';

This is essentially a thin wrapper on Ember Simple Auth. If you'd like to modify behaviour or catch events relating to Authentication, please refer to the Simple Auth Documentnation

Methods

Show Private Methods

authenticateUser

(
  • params
)

The authenticateUser call simply wraps the session#authenticate method provided by Ember Simple Auth.

Parameters:

  • params Object

    A javascript object with identification, password, and password confirmation (optional).


Returns:

Ember.RSVP.Promise:

A promise that resolves successfully on a successful authentication.

createAndAuthenticateUser

(
  • params
)

The createAndAuthenticateUser method attempts to create a new Spree User, and when successful, triggers the authenticateUser action.

Parameters:

  • params Object

    A javascript object with identification, password, and password confirmation (optional).


Returns:

Ember.RSVP.Promise:

A promise that resolves successfully on a successful create then authenticate.

extractAuthErrors

(
  • serverError
)

Extracts errors from failed Authenticate and Create actions, and sets them so that the UI can surface them.

Parameters:

  • serverError Object

    A JSON Payload containing server errors.


Returns:

Object:

A normalized errors object.

updateCurrentUser

The updateCurrentUser method attempts to save/update the current Spree user. It expects that changes to the session.currentUser model have been made in place, and doesn't take any arguments.


Returns:

Subclass of DS.Model:

The updated currentUser.

Events

Show Private Events

currentUserUpdateFailed

Triggered on the spree service whenever the updateCurrentUser call updates the current user successfully.


Event Payload
  • error Error

    The server error.

didCreateUser

Triggered on the spree service whenever a user is successfully created through the createAndAuthenticateUser call.


Event Payload
  • newUser DS.Model

    The newly created user model.

didUpdateCurrentUser

Triggered on the spree service whenever the updateCurrentUser call updates the current user successfully.


Event Payload
  • currentUser DS.Model

    The newly updated Current User.

userCreateFailed

Triggered on the spree service whenever the createAndAuthenticateUser call fails to create a new user.


Event Payload
  • error Error

    The server error.