繁体   English   中英

在 Appsync 解析器中访问 AWS Cognito 用户池属性

[英]Access AWS Cognito user pool attributes in Appsync resolver

我想检查当前用户是否设置了属性,如下所示:

#if(!${context.identity.claims.get("custom:organisation")})

... Do stuff

#end

我尝试了以下方法:

#if (${context.identity.claims["custom:organisation"]})
#if (${context.identity["custom:organisation"]})
#if ($context.identity.claims["custom:organisation"])
#if ($util.isNull($context.identity.claims["custom:organisation"]))

您应该能够在声明地图上使用 containsKey,如下所示:

#if($context.identity.claims.containsKey("custom:organisation"))

... Do stuff

#end

你应该像这样使用它:

${context.identity.claims.get("custom:organisation")}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM