I have to create an complete registration process for users. In rails, I usually use Devise. I have a rails api that is only responsible of the api. No view are produced by this application.
simple-auth handles session and authentication, not necessarily the “login” or “registration”.
What I usually do is create 2 forms that send AJAX requests with icajax and once they are successful, I use simple-auth’s authenticator & authorizer to handle the session.
And in your controller implement the action to create a user.
// app/controllers/signup.js
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
createUser: function() {
var email = this.get('userEmail');
var password = this.get('userPassword');
var user = this.store.createRecord('user', {
email: email,
password: password
});
user.save();
}
}
});
That’s it. You only need to implement an action in controller in Rails to handle the incoming POST data and saving it to the database. You mentioned that you’re using Devise, so it should be working by default then.
The registration process can be also rewritten to use Ember Component but this one is also a clean and easy solution.
I’m not sure if that’s wise, you are saving the password in the Ember.Store as plain text. You probably shouldn’t save any passwords in the front end of an app.
Yes it might be good to send the password only and not keep it on the model and in return you get a generated token from the api backend which you can put in the LocalStorage, on the model or however you wanna handle it.