登录
首页 >  Golang >  Go问答

在 beforeCreate 阻止功能期间自定义用户 JSON 响应格式(Google Identity Platform)

来源:stackoverflow

时间:2024-02-17 14:36:20 144浏览 收藏

IT行业相对于一般传统行业,发展更新速度更快,一旦停止了学习,很快就会被行业所淘汰。所以我们需要踏踏实实的不断学习,精进自己的技术,尤其是初学者。今天golang学习网给大家整理了《在 beforeCreate 阻止功能期间自定义用户 JSON 响应格式(Google Identity Platform)》,聊聊,我们一起来看看吧!

问题内容

我尝试在 beforeCreate 阻止函数中使用 Go 运行时来修改 Google Identity Platform 中新创建的用户。到目前为止,我已经解析并验证了 JWT,并且能够阻止或允许用户注册,但我不知道 Google 在修改正在处理的用户时期望什么 JSON 响应。

这些文档是专门为使用 Node.js SDK 的开发人员编写的,并且没有提及使用 Go 运行时实现相同内容时的预期 JSON 响应。我尝试在 JSON 响应中使用 {"disabled":"true"} ,但这在 NodeJS SDK 之外不起作用。有什么想法吗?


正确答案


创建前修改用户的完整 json 响应架构如下:

{
  "userrecord": {
    "updatemask": "customclaims,disabled,displayname,emailverified,photourl",
    "customclaims": {
      "examplerole": "exampleuserrole",
      "otherexampleclaim": "exampleuserclaim2",
      "otherexampleuserproperty": "exampleuserclaim3"
    },
    "disabled": true,
    "displayname": "example name",
    "emailverified": false,
    "photourl": "https://localhost/image.jpg"
  }
}

例如要禁用新用户:

{
  "userRecord": {
    "updateMask": "disabled",
    "disabled": true
  }
}

到这里,我们也就讲完了《在 beforeCreate 阻止功能期间自定义用户 JSON 响应格式(Google Identity Platform)》的内容了。个人认为,基础知识的学习和巩固,是为了更好的将其运用到项目中,欢迎关注golang学习网公众号,带你了解更多关于的知识点!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>