Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this integrate well with OAuth? (Google/twitter/etc) #11

Closed
brandonparsons opened this issue Oct 10, 2013 · 4 comments
Closed

Does this integrate well with OAuth? (Google/twitter/etc) #11

brandonparsons opened this issue Oct 10, 2013 · 4 comments
Labels

Comments

@brandonparsons
Copy link

No description provided.

@marcoow
Copy link
Member

marcoow commented Oct 10, 2013

Currently there isn't anything built in besides regular credentials based authentication. However, it's pretty easy to customize. The only 3 things you have to do is to implement your own login action in App.LoginController as sth. like this:

App.LoginController = Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin, {
  actions: {
    login: function() {
      var oAuthToken = //somehow retrieve the OAuth token here (an potentially exchange it against a custom token with your own server)...
      self.get('session').setup(oAuthToken);
      //if the user was redirected here, redo the originally attempted transition so they get redirected to their original route after they logged in
      var attemptedTransition = self.get('session.attemptedTransition');
      if (attemptedTransition) {
        attemptedTransition.retry();
        self.set('session.attemptedTransition', null);
      } else {
        self.transitionToRoute(Ember.SimpleAuth.routeAfterLogin);
      }
    }
  }
});

plus you need to override the setup method in Ember.SimpleAuth.Session:

Ember.Application.initializer({
  name: 'authentication',
  initialize: function(container, application) {
    Ember.SimpleAuth.Session.reopen({
      //the original code reads the auth token from the response JSON of the POST /session request
      setup: function(oAuthToken) {
        this.set('authToken', oAuthToken);
      }
    });
    Ember.SimpleAuth.setup(application);
  }
});

Also, instead of the original logout code that issues a DELETE /session request etc. you should implement your own logout that simply destroys the local session:

App.LogoutRoute = Ember.Route.extend({
  beforeModel: function() {
    this.get('session').destroy();
  }
});

@marcoow marcoow closed this as completed Oct 10, 2013
@brandonparsons
Copy link
Author

Thanks @marcoow - I'll be sure to give this library a shot once I'm there!

@reprasad
Copy link

Hi, Is there a way currently to authenticate using google with the latest version ?

@givanse
Copy link
Contributor

givanse commented Oct 28, 2014

Now you can use Torii: #273 (comment)

marcoow added a commit that referenced this issue Feb 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants