是否可以使用Azure B2C自定义策略中的声明转换来计算年龄组? [英] Is it possible to calculate age-group using Claims Transformations in an Azure B2C Custom Policy?

查看:73
本文介绍了是否可以使用Azure B2C自定义策略中的声明转换来计算年龄组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功创建了一个自定义策略,该策略要求用户的出生日期.

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" :

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.

谢谢!

推荐答案

我有用户的DOB,我想我可以获得当前的日期时间(TransformationMethod ="GetCurrentDateTime"在这里提到:https://docs.microsoft.com/zh-CN/azure/active-directory-b2c/manage-user-access#capture-terms-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.

用于根据用户的出生日期计算ageGroup的逻辑:

The logic that is used to calculate ageGroup from the user's date of birth:

  1. 尝试通过列表中的国家/地区代码查找国家/地区.如果找不到该国家,请使用默认.
  2. 如果country元素中存在MinorConsent节点:

  1. Try to find the country by the country code in the list. If the country is not found, fall back to Default.
  2. 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 be considered an adult. For example, if the current date is March 14, 2015, and MinorConsent is 18, the birth date must be no later than March 14, 2000.

b.比较最小生日和实际生日.如果最小出生日期早于用户的出生日期,返回未成年人作为年龄组计算.

b. Compare the minimum birth date with the actual birth date. If the minimum birth date is before the user’s birth date, the calculation returns Minor as the age group calculation.

我接下来要做的是量身定制注册体验取决于用户的年龄.

What I would like to do next is tailor the sign-up experience depending on the user's age.

您可以尝试使用年龄门控为此.

这篇关于是否可以使用Azure B2C自定义策略中的声明转换来计算年龄组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆