在 B2C 中预先创建用户并发送“重置密码流”-电子邮件预先填充

时间:2021-06-01 11:39:56

标签: azure-ad-b2c azure-ad-graph-api

我使用 Graph Api 在 B2C 中预先创建用户,然后发送带有“重置密码”-userflow URL 的电子邮件:

https://xxx.b2clogin.com/xxx.onmicrosoft.com/oauth2/v2.0/authorize?p=B2C_1_ResetPassword&client_id=xxx&nonce=defaultNonce&redirect_uri=https%3A%2F%2Fjwt.ms&scope=openid&response_type=code&prompt=login&code_challenge=xxx&login_hint=me@example.com

有没有办法预先填充电子邮件地址字段,这样用户就不需要手动编写它?我试过附加 login_hint 但它不起作用。

enter image description here

创建用户的代码:

        `var user = new User
        {
            DisplayName = displayName,
            AccountEnabled = true,
            UserType = "Member",
            Identities = new List<ObjectIdentity>()
            {
                new ObjectIdentity
                {
                    SignInType = "emailAddress",
                    Issuer = "xxx",
                    IssuerAssignedId = email
                },
            },
            PasswordProfile = new PasswordProfile
            {
                Password = password,
                ForceChangePasswordNextSignIn = false
            },
            PasswordPolicies = "DisablePasswordExpiration",
            AdditionalData = customAttributes
        };

        await graphClient.Users
            .Request()
            .AddAsync(user);`

1 个答案:

答案 0 :(得分:1)

login_hint 用于登录,文档 here。它在密码重置策略中不起作用,您可以反馈here

没有直接的方法可以在此流程中预先填充电子邮件地址。您可以使用 custom policies 来定义技术资料和用户旅程。试试看这个类似的 issue