Simple Admin Login, Ember.JS & Sails.JS

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 Likes

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.

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';
      }
    }
  }
});

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.

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.

It uses an old version of ember-cli and waterlock with this PR: Added a jwt flag for loginsuccess to return the token without the need o... by Globegitter · Pull Request #41 · waterlock/waterlock · GitHub, but check out GitHub - Globegitter/sails-ember-waterlock-auth: This is a demo for authentication with sails and ember