nestjs-oidc提供程序在配置中添加findAccount后获得路由404



所以我想添加findAccount来返回用户数据,在添加方法findAccount后,我得到了路由404/auth/:uid

这是我的配置

getConfiguration(): OidcConfiguration {
return {
findAccount(ctx, sub, token) {
console.log(ctx);
return this.account.findAccount(ctx, sub, token);
},
};
}

这是我的findAccount方法

findAccount(
ctx: KoaContextWithOIDC,
sub: string,
token?: any,
): Promise<Account> {
console.log('ctx', ctx, 'sub:', sub, 'token:', token);
this.accountId = sub;
return Promise.resolve({
accountId: this.accountId,
claims: this.claims,
});
}

我使用了nestjs-oidc提供程序包,但在示例中它没有使用findAccount方法

这个错误

request: {
method: 'GET',
url: '/auth?client_id=186ee568-4909-4b1e-a436-f59e6978008d&response_type=id_token&redirect_uri=https://oidcdebugger.com/debug&scope=openid%20profile&nonce=123&state=321',
header: {
host: 'localhost:3000',
connection: 'keep-alive',
'sec-ch-ua': '"Chromium";v="106", "Google Chrome";v="106", "Not;A=Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
dnt: '1',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36',
accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'sec-fetch-site': 'none',
'sec-fetch-mode': 'navigate',
'sec-fetch-user': '?1',
'sec-fetch-dest': 'document',
'accept-encoding': 'gzip, deflate, br',
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8,id;q=0.7',
cookie: '_session=7LRnAOX9PuuzOnT77sDJG; _session.sig=QwSKCjbNhh4FmDHAUW4JCPSqbWQ; _session.legacy=7LRnAOX9PuuzOnT77sDJG; _session.legacy.sig=b6FJjirtAyIWz7ZP6WwY_M2KJ6k'
}
},

谢谢你的建议

已解决,使用此代码

getConfiguration(): OidcConfiguration {
const { findAccount } = this.accountService;
return {
findAccount,
};
}

最新更新