mainmatter / ember-simple-auth

A library for implementing authentication/authorization in Ember.js applications.
https://ember-simple-auth.com
MIT License
1.92k stars 605 forks source link

Sign up example #73

Closed digitalplaywright closed 10 years ago

digitalplaywright commented 10 years ago

I looked at your ember simple auth examples, but I could not see anything documenting best practices for a sign-up user flow. Is there any documentation on recommended practices for a sign-up user flow?

zaplitny commented 10 years ago

Usually it's not related to oauth flow - just POST user data to your REST API

marcoow commented 10 years ago

Correct, signup is not part of the library. You might want to look at ember-data etc. for this.

Also just to be clear: Ember.SimpleAuth is not an OAuth library but a generic authentication/authorization library where one OAuth 2 grant type is simply the default option.

digitalplaywright commented 10 years ago

@marcoow Thank you for creating Ember.SimpleAuth.

I see that the sign-up flow is currently not part of the library, and you know better if it makes sense to provide an example of this. However, there seems to be a lot of edge-cases in the sign-up flow and a well thought-out reference implementation along the lines devise:install would be very helpful. For instance, a sign-up flow needs both error handling and auto-sign-in after sign-up. Getting an implementation of this is probably not hard, but doing it in a secure and robust way might be.

marcoow commented 10 years ago

Sure, would probably be nice to have a good example somewhere. Maybe you can contribute one for the examples? If you want to have auto-login on registration you can simply trigger session authentication with the username and password you already have in the signup controller when the signup request returns. Sth. like (assuming you want to use ember data):

App.SignupController  = Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin, {
  actions: {
    submit: function() {
      var _this = this;
      this.get('model').save().then(function(model) {
        _this.send('authenticate');
      });
    }
  }
});
digitalplaywright commented 10 years ago

I've added a repository with a sign-up example here:

An example API server is also available and referenced in the README. I have based this example upon work done by @kagemusha and hope to merge my changes into his repository.

Please let me know if you have any suggestions on how to improve the example, and thank you for this wonderful library!

marcoow commented 10 years ago

looks good - thanks!

andrewobrien commented 10 years ago

@digitalplaywright @marcoow thanks this is exactly what I have been looking for :)

digitalplaywright commented 10 years ago

@marcoow Many websites, like e.g. https://angel.co/login, has an optional social login. Is it possible with the grant flow used by Ember Simple Auth to sign up and login a user with Facebook? The API Server in this case need Facebook API access after user sign up.

marcoow commented 10 years ago

The OAuth 2.0 authenticator that Ember.SimpleAuth has is only one of many possible authenticators - please see the README as well as the examples (there's an example for Facebook authentication).

devinrhode2 commented 8 years ago

Where is the latest version of this example?? Did it get merged into the main repository?