dimanche 26 juillet 2015

Ember Simple-Auth empty payload

I just recently started learning Ember and I'm trying to make a login page using Ember Simple-auth and Laravel JWT packages. The problem is that my Ember submit action sends an empty payload. It seems like the getProperties function is not getting the input values, why is that? I've tried using every Google example that I could find with no success.

My controller:

// controllers/auth/login.js
import Ember from 'ember';
import LoginControllerMixin from 'simple-auth/mixins/login-controller-mixin';

export default Ember.Controller.extend(LoginControllerMixin, {
  actions: {
    authenticate: function() {
      var credentials   = this.getProperties('username', 'password'),
          authenticator = 'simple-auth-authenticator:token';

      this.get('session').authenticate(authenticator, credentials);
    }
  }
});

My login template:

// templates/auth/login.hbs
<form {{action "authenticate" on="submit"}}>
  <div class="alerts"></div>
  <div class="form-group">
    <label>
      <div class="title">Username</div>
      {{input value=username type="text" class="form-control" placeholder="Username"}}
    </label>
  </div>
  <div class="form-group">
    <label>
      <div class="title">Password</div>
      {{input value=password type="password" class="form-control" placeholder="Password"}}
    </label>
  </div>
  <button type="submit">Login</button>
</form>

Environment

ENV['simple-auth'] = {
  store: 'simple-auth-session-store:local-storage',
  authorizer: 'simple-auth-authorizer:token'
};
ENV['simple-auth-token'] = {
  refreshAccessTokens: true,
  timeFactor: 1,
  refreshLeeway: 300,
  serverTokenEndpoint: '/api/authenticate/',
};




Aucun commentaire:

Enregistrer un commentaire