首页 > 解决方案 > 在 B2C 中预先创建用户并发送“重置密码流程”-预先填充的电子邮件

问题描述

我正在使用 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,但它不起作用。

在此处输入图像描述

创建用户的代码:

        `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);`

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

解决方案


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

在此流程中没有直接预填充电子邮件地址的方法。您可以使用自定义策略来定义技术配置文件和用户旅程。试着看看这个类似的问题


推荐阅读