Skip to content

heyook/ember-cli-heyook-auth

Repository files navigation

Authentication for Ember projects

Set environment

var ENV = {
  //...

  HeyookAuth: {
    resourceName: "user",
    serverTokenEndpoint: 'api/users/sign_in'
  }

  //...
};

create resource

import DS from 'ember-data';

export default DS.Model.extend({
  email: DS.attr('string'),
  token: DS.attr('string')
});

create login route

import Ember from 'ember';
import ApplicationRouteMixin from 'ember-simple-auth/mixins/application-route-mixin';
import LoginRouteMixin from 'ember-cli-heyook-auth/mixins/login-route';

export default Ember.Route.extend(ApplicationRouteMixin, LoginRouteMixin);

in route, you can do

beforeModel: ->
    if @get('session.isAuthenticated')
      @transitionTo "dashboard"

or

actions:
    logout: ->
      @get('session').invalidate()

create login template

{{login-form
  onSubmit='submit'
  onRemember='updateRememberMe'}}

create simple auth authenticated route

import Ember from 'ember';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';

export default Ember.Route.extend(AuthenticatedRouteMixin);

About

Specific to Heyook ember projects

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •