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

I do not understand how I should include my own authenticator and user authorizer with ember cli.

Where to put it and what to include and how to do it. Unfortunately, the cli example for simple auth does not apply to the user authorizer and authenticator.

The build is successful, but when I start in the browser I get an error

TypeError: SimpleAuth.Authenticators is undefined 

I know that I am doing something wrong, but could you advise me or show me the correct documentation on how to do this, I can not 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 is as follows

 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!

+5
source share
1 answer

Change this to:

 ... import Base from "simple-auth/authenticators/base"; export default Base.extend({ ... 
+4
source

Source: https://habr.com/ru/post/1205354/


All Articles