【问题标题】:Access AWS Cognito user pool attributes in Appsync resolver在 Appsync 解析器中访问 AWS Cognito 用户池属性
【发布时间】:2020-04-12 09:02:22
【问题描述】:

我想检查当前用户是否有一个属性集,像这样:

#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"]))

【问题讨论】:

    标签: amazon-web-services amazon-cognito aws-appsync


    【解决方案1】:

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

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

    【讨论】:

    • 很抱歉没有回复您。你说得对。我的问题是执行查询的用户没有身份属性的访问权限。我必须编写一个 Lambda 函数来获取用户属性。
    猜你喜欢
    • 2019-07-22
    • 2022-01-21
    • 2020-09-03
    • 2019-02-13
    • 2021-11-27
    • 2018-03-25
    • 2022-07-04
    • 2023-03-19
    • 2017-04-12
    相关资源
    最近更新 更多