我怎么知道我网站上的某个人刚刚完成了注册' Azure B2C中的进程?我是否必须存储我自己的对象ID列表并检查它?我觉得无论如何我都不得不这样做......
答案 0 :(得分:5)
如果在注册策略中选择了此声明,则会收到'newUser'布尔声明。这只会发送一次,所以你需要采取行动。
答案 1 :(得分:0)
是的,您需要存储一个对象ID列表&在您的业务逻辑中相应地验证。
答案 2 :(得分:0)
设法解决了这个问题...
第1步(Azure门户)
第2步(代码)
//使用OpenIdConnectOptions
options.Events = new OpenIdConnectEvents()
{
OnRedirectToIdentityProvider = OnRedirectToIdentityProvider,
OnRemoteFailure = OnRemoteFailure,
OnAuthorizationCodeReceived = OnAuthorizationCodeReceived,
OnAuthenticationFailed = OnAuthenticationFailed,
OnMessageReceived = OnMessageReceived,
OnRedirectToIdentityProviderForSignOut = OnRedirectToIdentityProviderForSignOut,
OnRemoteSignOut = OnRemoteSignOut,
OnSignedOutCallbackRedirect = OnSignedOutCallbackRedirect,
OnTicketReceived = _onTicketReceivedInternal,
OnTokenResponseReceived = OnTokenResponseReceived,
OnTokenValidated = OnTokenValidated,
OnUserInformationReceived = OnUserInformationReceived
};
请注意_onTicketReceived内部任务...
private Task _onTicketReceivedInternal(TicketReceivedContext context)
{
this.OnTicketReceived(context);
//Check if new user
Claim newUserClaim = context.Principal.Claims.ToList().FirstOrDefault(x => x.Type == "newUser");
bool newUser = newUserClaim == null ? false : true;
//Trigger event
if (newUser)
this.OnSignUp(context);
return Task.FromResult(0);
}
//Custom method OnSignUp where an application can do something on user sign up
protected virtual Task OnSignUp(TicketReceivedContext context)
{
return Task.FromResult(0);
}