Simple Admin Login, Ember.JS & Sails.JS


#1

I’m trying to set up simple authentication for users who can edit content on an Ember app I’m building. I’m using Sails for backend, and was curious if anyone had any experience with this kind of setup already, using Ember-Simple-Auth or something similar?

Thanks!


#2

That is something I will work on in a future project, but ember-simple-auth seems like a good start and on the sailsjs side I have been keeping a close eye on https://github.com/davidrivera/waterlock

Since I didn’t need to use it yet I unfortunately can’t give any actual advice, but those are the two libraries I would probably start working with.


#3

I’m using passportJS, and at the Ember Application adapter I have the following code,

import Ember from 'ember';

export default Ember.Route.extend({
  model:function() {
    //Get currently logged in user model.
    return this.store.find('user', 'current');
  },

  actions: {
    error:function(reason) {
      //Upon unauthorized error, redirect to login.
      if(reason.status === 401) {
        document.location.href = '/login';
      }
    }
  }
});

#4

Those two look good I’ve gave it a spin yesterday. I haven’t yet managed to get things working from the ember side with simple auth.

If anyone has a working example I would be glad.

Started a git to try and get a good base for a sails api with auth and hook it to ember. https://github.com/wieseljonas/Sails-Ember-Auth

Seems like there needs to be some customization of waterlock to make it work with ember simple-auth.


#5

I started another project using waterlock. I can’t seem to get that working with ember either.

Wwas wondering if there was any updates on this? Otherwise I might try to refactor to use Passport.


#6

It uses an old version of ember-cli and waterlock with this PR: https://github.com/davidrivera/waterlock/pull/41, but check out https://github.com/Globegitter/sails-ember-waterlock-auth