Giter VIP home page Giter VIP logo

Comments (4)

marcoow avatar marcoow commented on May 12, 2024

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();
  }
});

from ember-simple-auth.

brandonparsons avatar brandonparsons commented on May 12, 2024

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

from ember-simple-auth.

reprasad avatar reprasad commented on May 12, 2024

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

from ember-simple-auth.

givanse avatar givanse commented on May 12, 2024

Now you can use Torii: #273 (comment)

from ember-simple-auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.