在构建自定义身份验证策略时,我获得了一个Unable to log in using the strategy "SSO",当需要时,我使用create钩子创建我的用户。
一切都很顺利,包括我的钩子:
async create(_request: any, credentials: { id: string }, kuid: string) {
// Create user credential
const [err] = await to(
this.ssoRepository.create(
{
_id: credentials.id,
kuid,
},
{ refresh: "wait_for" },
),
);
if (err) {
throw new this.context.errors.InternalError(`Error while creating SSO credentials for user ${kuid}.`);
}
return { _id: credentials.id };
}然后我使用以下命令使用它
// If user not exists, we create the user
let createdUser: any;
[err, createdUser] = await to(
this.kuzzle.query({
action: "createUser",
body: {
content: {
profileIds: ["default"],
...ssoUser,
courses: [],
favorites: [],
},
credentials: {
SSO: {
id: ssoUser!.id,
},
},
},
controller: "security",
refresh: "wait_for",
}),
);
if (err) {
throw new this.context.errors.InternalError(err.message);
}
return { kuid: createdUser._id };但是我得到了以下错误
代码:0 errorName:“未记录的错误”消息:“无法使用策略”SSO“登录”
你知道为什么我会有这样的问题吗?
问候
发布于 2019-07-31 22:48:07
我不得不用
return { kuid: createdUser.result._id };而不是
return { kuid: createdUser._id };因为kuzzle包装了创建的用户内容
https://stackoverflow.com/questions/57293497
复制相似问题