Giter Club home page Giter Club logo

Comments (16)

marcoow avatar marcoow commented on May 22, 2024

I pushed a fix for that some hours ago.

Of course the strategies branch isn't released yet so no guarantees for it being ready for production...

Am 15.01.2014 um 12:13 schrieb Michaël Gallego [email protected]:

Hi,

I'm trying to use the new strategies branch, however I'm encountering an error:

TypeError: 'null' is not an object (evaluating 'this.get('authenticator').create')

It seems I've followed the example. As JS is not my primary language I'm not sure to be able to spot where the problem comes from.

Thanks!


Reply to this email directly or view it on GitHub.

from ember-simple-auth.

bakura10 avatar bakura10 commented on May 22, 2024

I'm already using the latest build :). Still have the error :)

from ember-simple-auth.

marcoow avatar marcoow commented on May 22, 2024

Any chance you can give me access to the code or set up a jsbin or so?

Am 15.01.2014 um 12:42 schrieb Michaël Gallego [email protected]:

I'm already using the latest build :). Still have the error :)


Reply to this email directly or view it on GitHub.

from ember-simple-auth.

bakura10 avatar bakura10 commented on May 22, 2024

It's in a private repository, but for now it's a completely empty app.

The initializer:

Ember.Application.initializer({
  name: 'authentication',
  initialize: function(container, application) {
    Ember.SimpleAuth.setup(application);
  }
});

Login controller:

module.exports = App.LoginController = Ember.Controller.extend(Ember.SimpleAuth.AuthenticationControllerMixin);

Login route:

module.exports = App.LoginRoute = Ember.Route.extend();

Application route:

module.exports = App.ApplicationRoute = Ember.Route.extend(Ember.SimpleAuth.ApplicationRouteMixin);

And the login template:

<form {{action authenticate on='submit'}}>
    <div class="control-group">
        <label for="identification">Login</label>
        {{view Ember.TextField id='identification' valueBinding='identification'}}
    </div>

    <div class="control-group">
        <label for="password">Password</label>
        {{view Ember.TextField id='password' type='password' valueBinding='password'}}
    </div>

    <button type="submit">Login</button>
</form>

from ember-simple-auth.

marcoow avatar marcoow commented on May 22, 2024

That’s what was updated earlier today in the examples: you have to mix in
the LoginControllerMixin if you want to use a strategy that takes user
credentials:

module.exports = App.LoginController =
Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin);

2014/1/15 Michaël Gallego [email protected]

It's in a private repository, but for now it's a completely empty app.

The initializer:

Ember.Application.initializer({
name: 'authentication',
initialize: function(container, application) {
Ember.SimpleAuth.setup(application);
}});

Login controller:

module.exports = App.LoginController = Ember.Controller.extend(Ember.SimpleAuth.AuthenticationControllerMixin);

Login route:

module.exports = App.LoginRoute = Ember.Route.extend();

Application route:

module.exports = App.ApplicationRoute = Ember.Route.extend(Ember.SimpleAuth.ApplicationRouteMixin);

And the login template:

Login {{view Ember.TextField id='identification' valueBinding='identification'}}
Password {{view Ember.TextField id='password' type='password' valueBinding='password'}}
Login


Reply to this email directly or view it on GitHubhttps://github.com//issues/62#issuecomment-32359291
.

Marco Otte-Witte
[email protected]
http://simplabs.com

from ember-simple-auth.

bakura10 avatar bakura10 commented on May 22, 2024

Awesome, it works :D. Thanks!

from ember-simple-auth.

bakura10 avatar bakura10 commented on May 22, 2024

Hi,

I've updated to the latest release (the official release) and now I have the following error:

Uncaught TypeError: Cannot call method 'authenticate' of undefined. It happens in the "authenticate" method of the AuthenticationControllerMixin.

Is this an expected issue?

from ember-simple-auth.

marcoow avatar marcoow commented on May 22, 2024

No, certainly not expected. Looks like your session is not set. Did you update anything else together with Ember.SimpleAuth?

from ember-simple-auth.

bakura10 avatar bakura10 commented on May 22, 2024

No, I didn't update anything else. :(.

from ember-simple-auth.

marcoow avatar marcoow commented on May 22, 2024

can you change your login controller to this:

module.exports = App.LoginController = Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin, {
  actions: {
    authenticate: function() {
      console.log(this.get('session'));
      this._super();
    }
  }
});

Also a stack trace for the error would be helpful. Best would of course be a jsbin showing the error.

from ember-simple-auth.

bakura10 avatar bakura10 commented on May 22, 2024

I got "undefined". Here is the code (like previous time):

The initializer:

module.export = (function() {
  Ember.Application.initializer({
    name: 'authentication',

    initialize: function(container, application) {
      Ember.SimpleAuth.setup(application, {
        routeAfterInvalidation: 'login',
        routeAfterAuthentication: 'projects'
      });
    }
  });

  Ember.SimpleAuth.Authenticators.OAuth2.reopen({
    serverTokenEndpoint: 'http://connect.saas-metrics.localhost/oauth/token'
  });
});

The application route:

module.exports = App.ApplicationRoute = Ember.Route.extend(Ember.SimpleAuth.ApplicationRouteMixin);

The login controller:

module.exports = App.LoginController = Ember.Controller.extend(Ember.SimpleAuth.LoginControllerMixin, {
  /**
   * Error message if login fails
   *
   * @type {string}
   */
  errorMessage: null,

  actions: {
    /**
     * Set an error message when authentication fails
     */
    sessionAuthenticationFailed: function(error) {
      this.set('errorMessage', JSON.parse(error).error_description);
    }
  }
});

And finally the login template:

<h2>Login Template</h2>

<form {{action authenticate on='submit'}}>
    <div class="control-group">
        <label for="identification">Login</label>
        {{view Ember.TextField id='identification' valueBinding='identification'}}
    </div>

    <div class="control-group">
        <label for="password">Password</label>
        {{view Ember.TextField id='password' type='password' valueBinding='password'}}
    </div>

    <button type="submit">Login</button>
</form>

{{#if errorMessage}}
    <p>{{ errorMessage }}</p>
{{/if}}

Sorry if I miss something again :(.

from ember-simple-auth.

bakura10 avatar bakura10 commented on May 22, 2024

Btw, it would be a nice addition if Ember-Simple-Auth would extract automatically the error message, as it's standardized to be under the "error_description" key. What do you think ? :)

from ember-simple-auth.

marcoow avatar marcoow commented on May 22, 2024

Btw, it would be a nice addition if Ember-Simple-Auth would extract automatically the error message, as it's standardized to be under the "error_description" key. What do you think ? :)

Sounds like a good idea to add that to Authenticators.OAuth2.

Regarding your problem - is Ember.SimpleAuth.setup running before your controller is created? Maybe the module transpilation somehow changes the order of things there so that the initializer runs later or so?

from ember-simple-auth.

bakura10 avatar bakura10 commented on May 22, 2024

No, it seems initializers are run before controllers. I'll dig a bit more tomorrow...

from ember-simple-auth.

bakura10 avatar bakura10 commented on May 22, 2024

I found it. Actually, the syntax I tried to use:

module.export = (function() {
  Ember.Application.initializer({
    name: 'authentication',

    initialize: function(container, application) {
      alert('ok');
      Ember.SimpleAuth.setup(application, {
        routeAfterInvalidation: 'login',
        routeAfterAuthentication: 'projects'
      });
    }
  });

  Ember.SimpleAuth.Authenticators.OAuth2.reopen({
    serverTokenEndpoint: 'http://connect.saas-metrics.localhost/oauth/token'
  });
});

for module exporting was wrong and the initializer was not called. Here is the correct one:

module.export = Ember.Application.initializer({
    name: 'authentication',

    initialize: function(container, application) {
      alert('ok');
      Ember.SimpleAuth.setup(application, {
        routeAfterInvalidation: 'login',
        routeAfterAuthentication: 'projects'
      });
    }
  });

  Ember.SimpleAuth.Authenticators.OAuth2.reopen({
    serverTokenEndpoint: 'http://connect.saas-metrics.localhost/oauth/token'
  });

I need to learn more about modules. I thought I needed to do that so that Ember.SimpleAuth.Authenticators get wrapped too

from ember-simple-auth.

marcoow avatar marcoow commented on May 22, 2024

cool

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.