Giter VIP home page Giter VIP logo

Comments (11)

adamlc avatar adamlc commented on May 12, 2024

This is also happening to me too using the latest canary build. I'm not sure whats causing it!

According to the documentation send() should bubble up the tree, therefore reaching the ApplicationRoute and triggering the login action. But for some reason it isn't working.

I've tried changing the order of my code so that the ApplicationRoute is created early on in the code, incase it wasn't initialised quick enough but this doesn't seem to make any difference for me :(

from ember-simple-auth.

marcoow avatar marcoow commented on May 12, 2024

I think this is a similar problem as the one described here: https://gist.github.com/machty/6879857 (see point 4 in the list) - not sure how to fix it yet...

from ember-simple-auth.

marcoow avatar marcoow commented on May 12, 2024

Changing triggerLogin in Ember.SimpleAuth.AuthenticatedRouteMixin from this:

triggerLogin: function(transition) {
  this.set('session.attemptedTransition', transition);
  this.send('login');
}

to this:

triggerLogin: function(transition) {
  this.set('session.attemptedTransition', transition);
  App.__container__.lookup('route:application')._actions['login'].apply(this);
}

actually does fix it but of course isn't desirable. Problem really seems to be that there's no active view hierarchy after a fresh reload that the action could be triggered on. Maybe somehow it can be triggered on the transition or so...

from ember-simple-auth.

marcoow avatar marcoow commented on May 12, 2024

Ok, got it - solution is here: machty/ember.js@160a41c -call #send on the transition rather than on this:

triggerLogin: function(transition) {
  this.set('session.attemptedTransition', transition);
  transition.send('login');
}

Transition#send is only available with Ember.js 1.2 though. Not sure how I want to handle that - probably ok to require Ember.js 1.2 I guess... What do you guys think?

from ember-simple-auth.

balinterdi avatar balinterdi commented on May 12, 2024

Thank you for fixing it so fast, Marco.

I think it is ok to require Ember 1.2 or higher. I would even say that it is required (not just recommended) since that is quite a serious bug, in my opinion.

from ember-simple-auth.

marcoow avatar marcoow commented on May 12, 2024

What I'm doing is this now:

if (Ember.canInvoke(transition, 'send')) {
  transition.send('login');
} else {
  this.send('login');
}

That means the bug is fixed for 1.2 without completely breaking functionality for < 1.2. I think I'd remove that again some time after 1.2 is officially released...

from ember-simple-auth.

balinterdi avatar balinterdi commented on May 12, 2024

Looks good. Thank you for this library!

from ember-simple-auth.

jmvandamme avatar jmvandamme commented on May 12, 2024

Hi (and happy new year !), I still have the initial problem mentioned by balinterdi. I run my app with ember 1.2.
Why don't you simply use ?
this.transitionTo(Ember.SimpleAuth.loginRoute);
This works for me but I would prefer keep your code ;-)

from ember-simple-auth.

marcoow avatar marcoow commented on May 12, 2024

Can you add a stack trace? Would be strange if you really saw the same error as above with 1.2.

from ember-simple-auth.

jmvandamme avatar jmvandamme commented on May 12, 2024

Sincerely sorry for this mistake in my first post :( . I've changed my bower.json file to upgrade in 1.2 but, you know, it's not enough... So, It works perfectly now. Thanks a lot for your help and also for your component.

from ember-simple-auth.

GendelfLugansk avatar GendelfLugansk commented on May 12, 2024

Hi, everyone. I have the same issue, as described here, but without any errors in my console. I use Ember 1.13.3.

UPD. Problem is in my code: my login route is nested to 'lang' route:

Router.map(function () {
  this.route("lang", { path: '/:lang' }, function () {
    this.route('404', { path: '/*:' });
    this.route('login', { path: '/login' });
    this.route('countries', {path: '/countries'}, function() {
      this.route('country', {path: '/:id'});
    });
  });
});

Protected routes are lang.countries and lang.countries.country.

UPD2. I changed sessionRequiresAuthentication action in application-route-mixin and this helped me to solve this issue:

sessionRequiresAuthentication: function () {
  var attemptedTransition = this.get(Configuration.sessionPropertyName).get('attemptedTransition');
  var params;
  if (attemptedTransition && attemptedTransition.params) {
    var authRouteParts = Configuration.authenticationRoute.split('.');
    var route = '';
    for (var i = 0; i < authRouteParts.length; i++) {
      if (route !== '') {
        route += '.';
      }
      route += authRouteParts[i];
      if (attemptedTransition.params[route] !== undefined) {
        for (var k in attemptedTransition.params[route]) {
          if (attemptedTransition.params[route].hasOwnProperty(k)) {
            if (params === undefined) {
              params = {};
            }
            params[k] = attemptedTransition.params[route][k];
          }
        }
      }
    }
  }
  if (params !== undefined) {
    this.transitionTo(Configuration.authenticationRoute, params);
  } else {
    this.transitionTo(Configuration.authenticationRoute);
  }
}

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.