gpt4 book ai didi

ember.js - 如何在 ember cli 中为 ember simple-auth 使用自定义授权器和自定义验证器

转载 作者:行者123 更新时间:2023-12-04 20:05:05 25 4
gpt4 key购买 nike

我不明白我应该如何在 ember cli 中包含我的自定义身份验证器和自定义授权器。

把它放在哪里,包括什么以及如何做。不幸的是,提供的 simple-auth cli 示例不包括自定义授权器和身份验证器。

构建成功,但在浏览器中运行时,出现错误

TypeError: SimpleAuth.Authenticators is undefined

我知道我做错了什么,但是您能否指导我或将我指向有关如何执行此操作的正确文档,我找不到任何内容:(
我的初始化程序看起来像这样:
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);
}
};

我的身份验证器看起来像这样
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() {
[...]
}
});

我错过了什么?提前致谢!

最佳答案

将其更改为:

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

export default Base.extend({
...

关于ember.js - 如何在 ember cli 中为 ember simple-auth 使用自定义授权器和自定义验证器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26526960/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com