首页 > 解决方案 > 如何使用 MS 身份平台在 OnSignIn 之后触发自定义方法

问题描述

我有一个使用 Identity Platform 身份验证的 Blazor .Net 5 应用程序。开箱即用,这一切都很好,但是,我想在 .Net/AzureAD 完成它之后触发我自己的方法,但我不确定如何最好地做到这一点。

因此,用户单击指向@MicrosoftIdentity/Account/SignIn 的“登录”链接,MS 接管并处理所有事情,并按照设置说明返回到回调路径“/signin-oidc”。如何在此过程完成后,我会立即运行以下代码吗?

MyCustomPostSignInLogic()
{
    // All my code to run once, post sign in
}

作为一项附加功能,是否还有一种方法可以干预 .Net 自动登录用户,尽管他们已经过身份验证?

MyCustomOverrideSignInLogic()
{
   // run this code and perhaps decide not to authenticate a user, despite them successfully completing MS auth.  Maybe we have blacklisted a user, and despite them having a valid MS account, don't want them to specifically authenticate against our app.
}

标签: c#asp.net-coreblazor-server-sidemicrosoft-identity-platform

解决方案


推荐阅读