dimanche 3 mai 2015

ember-cli-simple-auth-devise not sending the right attributes

I'm trying to get ember-cli-simple-auth-devise to work. I already did the modifications to Rails as requested by http://ift.tt/1gQsesQ but I found the emberjs was sending the wrong attributes: account[identification] and account[password] instead of user[email] and user[password].

I changed

ENV['simple-auth-devise'] = {
  resourceName: 'account'
};

to

ENV['simple-auth-devise'] = {
  resourceName: 'user'
};

and login.hbs to contain:

<form {{action 'authenticate' on='submit'}}>
    <label for="email">Email</label>
    {{input value=email placeholder='Email'}}
    <label for="password">Password</label>
    {{input value=password placeholder='Password' type='password'}}
    <button type="submit">Login</button>
</form>

so that the form generates a form field called email instead of identification. In the controller:

export default Ember.Controller.extend({
    actions: {
        authenticate: function() {
            var data = this.getProperties('email', 'password');
            return this.get('session').authenticate('simple-auth-authenticator:devise', data);
        }
    }
});

data has what I want:

{email: "email@address.com", password: "supersecret"}

but Rails only

{"user"=>{"password"=>"supersecret"},
 "controller"=>"sessions",
 "action"=>"create"}"

The email is missing. How do I make the email reach Rails?




Aucun commentaire:

Enregistrer un commentaire