如何在ember cli中使用自定义授权器和自定义验证器来进行ember simple-auth [英] How to use a custom authorizer and custom authenticator for ember simple-auth in ember cli

查看:137
本文介绍了如何在ember cli中使用自定义授权器和自定义验证器来进行ember simple-auth的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白我应该如何将我的自定义验证器和自定义authorizo​​r包含在ember cli中。

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

放在哪里,要包含什么以及如何做。不幸的是,简单认证的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);
  }
};

我的Authentato r看起来像这样

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!

推荐答案

更改为:

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

export default Base.extend({
...

这篇关于如何在ember cli中使用自定义授权器和自定义验证器来进行ember simple-auth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆