问题描述
我已经成功创建了一个自定义策略,该策略要求用户的出生日期.
I have successfully created a custom policy that asks for a user's date-of-birth.
接下来我要做的就是根据用户的年龄调整注册体验.
What I would like to do next is tailor the sign-up experience depending on the user's age.
我希望我可以使用Claims转换和前提条件来做到这一点,但是通过查看我发现的文档,我看不到如何做到这一点.有可能吗?
I am hoping that I could do this using claims transformations and preconditions, but looking through the documentation that I have found, I cannot see how to do it. Is it possible?
我有用户的DOB,我想我可以获取当前日期时间(此处提到 TransformationMethod ="GetCurrentDateTime"
: https://docs.microsoft.com/zh-cn/azure/active-directory-b2c/manage-user-access#capture-of-use-agreement ),但我看不到如何计算差异(针对年龄),或在前提条件.
I have the user's DOB, I think I can get the current date-time (TransformationMethod="GetCurrentDateTime"
is mentioned here: https://docs.microsoft.com/en-us/azure/active-directory-b2c/manage-user-access#capture-terms-of-use-agreement), but I can't see how to calculate the difference (for age), or use the age in a precondition.
我唯一想到的解决方法是通过REST API声明交换来计算年龄(或年龄组),但我不希望不增加系统的复杂性.
The only work-around I can think of is to calculate the age (or age-group), via a REST API claim exchange, but I would prefer not to add more complexity to the system.
谢谢!
推荐答案
用于根据用户的出生日期计算ageGroup的逻辑:
The logic that is used to calculate ageGroup from the user's date of birth:
- 尝试通过列表中的国家/地区代码查找国家/地区.如果找不到该国家,请使用默认.
-
如果country元素中存在MinorConsent节点:
- Try to find the country by the country code in the list. If the country is not found, fall back to Default.
If the MinorConsent node is present in the country element:
a.计算用户必须出生的日期被认为是成年人.例如,如果当前日期是3月14日,2015年,并且MinorConsent是18岁,出生日期不得早于2000年3月14日.
a. Calculate the date that the user must have been born on to beconsidered an adult. For example, if the current date is March 14,2015, and MinorConsent is 18, the birth date must be no later thanMarch 14, 2000.
b.比较最小生日和实际生日.如果最小出生日期早于用户的出生日期,返回未成年人作为年龄组计算.
b. Compare the minimum birth date with the actual birth date. If theminimum birth date is before the user’s birth date, the calculationreturns Minor as the age group calculation.
您可以尝试使用年龄门控为此.
这篇关于是否可以使用Azure B2C自定义策略中的声明转换来计算年龄组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!