-
Notifications
You must be signed in to change notification settings - Fork 605
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
Bug when using new strategy #62
Comments
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...
|
I'm already using the latest build :). Still have the error :) |
Any chance you can give me access to the code or set up a jsbin or so?
|
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> |
That’s what was updated earlier today in the examples: you have to mix in module.exports = App.LoginController = 2014/1/15 Michaël Gallego notifications@github.com
Marco Otte-Witte |
Awesome, it works :D. Thanks! |
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? |
No, certainly not expected. Looks like your session is not set. Did you update anything else together with Ember.SimpleAuth? |
No, I didn't update anything else. :(. |
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. |
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 :(. |
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 Regarding your problem - is |
No, it seems initializers are run before controllers. I'll dig a bit more tomorrow... |
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 |
cool |
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!
The text was updated successfully, but these errors were encountered: