Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a custom authorizer and custom authenticator for ember simple-auth in ember cli

I don't understand how I'm supposed to include my custom authenticator and custom authorizor with ember cli.

Where to put it and what to include and how to do it. The cli example for simple-auth provided unfortunately does not cover custom authorizer and authenticator.

The build is successfully, but when running it in the browser, I get the error

TypeError: SimpleAuth.Authenticators is undefined

I'm aware that I'm doing something wrong, but could you please guide me or point me to the right documentation on how to do this, I can't find anything :( My initializer looks like this:

import Ember from 'ember';
import CustomAuthenticator from "../models/customauthenticator";

export default {
  name : 'authentication',
  before : 'simple-auth',
  initialize : function(container) {
    container.register('authenticator:custom', CustomAuthenticator);
    //container.register('authorizer:custom', CustomAuthorizer);
  }
};

My authenticator looks like this

import Ember from "ember";
import App from '../app';
import SimpleAuth from "simple-auth/authenticators/base";

App.CustomAuthenticator = SimpleAuth.Authenticators.Base.extend({
  tokenEndpoint: '/api/RestUser.php/users/core/access/',

  restore: function(data) {
    [...]
  },
  authenticate: function(credentials) {
    [...]
  },
  invalidate: function() {
    [...]
  }
});

What am I missing? Thanks in advance!

like image 246
Preexo Avatar asked Sep 30 '22 13:09

Preexo


1 Answers

Change that to:

...
import Base from "simple-auth/authenticators/base";

export default Base.extend({
...
like image 74
marcoow Avatar answered Oct 11 '22 14:10

marcoow