在 Azure Active Directory B2C 中设置配置文件编辑流Set up a profile editing flow in Azure Active Directory B2C

开始之前,请使用上面的选择器选择要配置的策略类型。Before you begin, use the selector above to choose the type of policy you’re configuring. Azure AD B2C 提供了两种定义用户如何与应用程序交互的方法:通过预定义的用户流,或者通过完全可配置的自定义策略Azure AD B2C offers two methods of defining how users interact with your applications: though predefined user flows, or through fully configurable custom policies. 对于每种方法,本文中所需的步骤都不同。The steps required in this article are different for each method.

配置文件编辑流Profile editing flow

借助配置文件编辑策略,用户可以管理其配置文件属性,例如显示名称、姓氏、名字、城市等。Profile editing policy lets users manage their profile attributes, like display name, surname, given name, city, and others. 配置文件编辑流涉及以下步骤:The profile editing flow involves following steps:

  1. 使用本地帐户或社交帐户注册或登录。Sign-up or sign-in, with local or social account. 如果会话仍处于活动状态,Azure AD B2C 将为用户授权并跳到下一步骤。If the session is still active, Azure AD B2C authorizes the user, and skips to the next step.
  2. Azure AD B2C 从目录中读取用户配置文件,并使用户可编辑属性。Azure AD B2C reads the user profile from the directory, and let the user edit the attributes.

配置文件编辑流

先决条件Prerequisites

在 Azure Active Directory B2C 中注册 Web 应用程序(如果尚未这样做)。If you haven't already done so, register a web application in Azure Active Directory B2C.

创建配置文件编辑用户流Create a profile editing user flow

如果希望用户能够在你的应用程序中编辑其个人资料,请使用个人资料编辑用户流。If you want to enable users to edit their profile in your application, you use a profile editing user flow.

  1. 在 Azure AD B2C 租户概述页面的菜单中,选择“用户流”,然后选择“新建用户流”。 In the menu of the Azure AD B2C tenant overview page, select User flows, and then select New user flow.
  2. 在“创建用户流”页面上,选择“个人资料编辑”用户流 。On the Create a user flow page, select the Profile editing user flow.
  3. 在“选择版本”下,选择“建议”,然后选择“创建” 。Under Select a version, select Recommended, and then select Create.
  4. 输入该用户流的 名称Enter a Name for the user flow. 例如 profileediting1For example, profileediting1.
  5. 对于“标识提供者”,请选择“电子邮件登录” 。For Identity providers, select Email sign-in.
  6. 对于“用户属性”,请选择你希望客户能够在其个人资料中编辑的属性。For User attributes, choose the attributes that you want the customer to be able to edit in their profile. 例如,选择“显示更多”,然后选择“显示名称”和“职务”所对应的属性和声明。 For example, select Show more, and then choose both attributes and claims for Display name and Job title. 单击 “确定”Click OK.
  7. 单击“创建”以添加用户流。Click Create to add the user flow. 名称中会自动追加前缀 B2C_1A prefix of B2C_1 is automatically appended to the name.

测试用户流Test the user flow

  1. 选择已创建的用户流以打开其概览页,然后选择“运行用户流”。Select the user flow you created to open its overview page, then select Run user flow.
  2. 对于“应用程序”,请选择前面已注册的名为 webapp1 的 Web 应用程序。For Application, select the web application named webapp1 that you previously registered. “回复 URL”应显示为 https://jwt.msThe Reply URL should show https://jwt.ms.
  3. 单击“运行用户流”,然后使用前面创建的帐户登录。Click Run user flow, and then sign in with the account that you previously created.
  4. 现在,你可以更改用户的显示名称和职务。You now have the opportunity to change the display name and job title for the user. 单击 “继续”Click Continue. 令牌将返回到 https://jwt.ms 并显示出来。The token is returned to https://jwt.ms and should be displayed to you.

创建配置文件编辑策略Create a profile editing policy

自定义策略是上传到 Azure AD B2C 租户的一组 XML 文件,用于定义用户旅程。Custom policies are a set of XML files you upload to your Azure AD B2C tenant to define user journeys. 我们提供了初学者包,其中有多个预构建策略,包括注册和登录、密码重置以及配置文件编辑策略。We provide starter packs with several pre-built policies including: sign-up and sign-in, password reset, and profile editing policy. 有关详细信息,请参阅 Azure AD B2C 中的自定义策略入门For more information, see Get started with custom policies in Azure AD B2C.

后续步骤Next steps