使用AWS Cognito身份创建用户 [英] creating user using AWS cognito identity

查看:129
本文介绍了使用AWS Cognito身份创建用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习使用AWS lambda,dynamodb,cogito同步创建无服务器API服务器。直到我对 users 表感到困惑之前,一切都进行得很好。

I am learning to create a serverless API server using AWS lambda, dynamodb, cogito sync. It was going well until I got confused with users table.

所以基本上,我正在尝试制作Twitter克隆API。因此,作为用户,我应该可以创建帖子,关注其他用户,等等。

So basically, I am trying to make twitter clone API. So as user I should be able to create post, follow another users etc.

注册和登录已由Cognito Identity成功处理,问题是如何访问用户认知数据?用户可以具有跟进跟随者的属性,其中包含其他用户ID。

Signup and Signin are successfully handled by Cognito Identity, the problem is how do I access the Users data on the cognito? A user can have following and followers attributes which contains other users ID.

我目前所做的,在我使用cognito身份注册的应用程序上,然后我将再次调用API网关,以在dynamodb上创建 user 。因此,基本上有两个单独的用户数据。我不确定这是否是正确的方法。

What I did currently, on the app I register using cognito identity then I will make another call to the API gateway to create a user on dynamodb. So basically there are two separate users data. I am not sure if this is the correct way to do this.

我应该在 cognito 上打电话吗后端而不是应用程序上?我应该为此使用单独的 users 表吗?

Should I make a call on cognito on the backend instead on the app? Should i have separate users table for this?

ionic <上的示例前端代码

$scope.signup = function() {
  $ionicLoading.show({
    template: 'Registering user...'
  });
  // this is the factory for signing up
  awsCognitoIdentityFactory.signUp($scope.user.email, $scope.user.name, $scope.user.email, $scope.user.password,
    function(err, result) {
      if (err) {
        errorHandler(err);
        return false;
      }
      // creating user on the api
      User.create($scope.user).then(function(response) {
        console.log(response);
      });
      // store locally
      store.set('user', $scope.user);

      $ionicLoading.hide();
      $scope.$apply();

      $scope.user = {}; //clear register form
      $state.go('confirmation');
    });
  return true;
};


推荐答案

听起来您正在使用Cognito用户池,在这种情况下,您可以使用 GetUser API 。给定用户上下文,它将返回针对该用户存储的所有属性。

It sounds like you're using Cognito User Pools, in which case you can use the GetUser API. Given context for the user, it will return all attributes stored against that user.

我无法评论存储用户元数据的最佳方法,因为它会根据您的应用程序的具体情况和需求而有很大的不同,但是值得一读自定义属性的Cognito系统,这样您就可以针对用户存储自定义数据。可以从Cognito控制台配置/添加这些内容。

I can't comment on the best way to store user metadata as it will vary greatly based on the specifics and needs of your app, but it's probably worth reading up on Cognito's system of custom attributes, which lets you store custom data against users. These can be configured/added from the Cognito console.

这篇关于使用AWS Cognito身份创建用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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