Cognitex- Library for managing user accounts through AWS Cognito service.

in utopian-io •  6 years ago 

Repository

https://github.com/Skoda091/cognitex

Details

The following functionality is covered:

  • User registration
  • Confirm registration (with the confirmation code received from AWS, by email)
  • User authentication
  • Fetch user data by an access token
  • Fetch user data by username
  • Change user password
  • Update user attributes
  • Reset a forgotten password

Installation

To use cognitex with your projects, edit your mix.exs file to add it as a dependency:

def deps do
  [
    {:cognitex, "~> 0.1.0"}
  ]
end

Configuration

An example config might look like this:

config :aws,
  key: "<AWS_ACCESS_KEY_ID>",
  secret: "<AWS_SECRET_ACCESS_KEY>",
  region: "<AWS_REGION>",
  client_id: "<AWS_CLIENT_ID>",
  user_pool_id: "<AWS_USER_POOL_ID>"

Set up AWS Cognito with the correct configuration

First, we will set up a new AWS Cognito user pool with the correct configuration.

  1. Visit your AWS console and go to the AWS Cognito service. Click on “Manage your User Pools” and click “Create a User Pool”.
  2. Specify a name for your pool and click “Review Defaults”.
  3. Optional: edit the password policy to remove some of the requirements. If you are just testing, using simple passwords will make it easier.
  4. Click the “edit client” link. Specify a name for your app and be sure to disable the client secret and enable the ADMIN_NO_SRP_AUTH option.
  5. Click “Create pool”. Take note of the Pool Id at the top of the page and click on the apps page. Here, take note of the App client id.

Usage

iex> Cognitex.sign_up("[email protected]", "Test123", name: "John", family_name: "Smith")
{:ok,
  %{
    "CodeDeliveryDetails" => %{
      "AttributeName" => "email",
      "DeliveryMedium" => "EMAIL",
      "Destination" => "j***@e***.co"
      },
      "UserConfirmed" => false,
      "UserSub" => "uuid"
      }
   }

iex> Cognitex.sign_up("[email protected]", "Test123", name: "John", family_name: "Smith")

{:error,
  %{
    message: "An account with the given email already exists.",
    status: "UsernameExistsException"
  }
}

Full documentation is available here

Github

https://github.com/Skoda091

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Thank you for your contribution. I can see this is your first contribution to Utopian. I would suggest you to go through the Utopian Guidelines before contributing. Few such guidelines are

  • To be considered for potential reward, Bug Fixes and New Features should be submitted via Pull Requests. The Pull Request should have been merged within the past 14 days.
  • Updates on Own Projects may be committed directly, without a Pull Request. To be considered for potential reward, commits should not be older than 14 days.

As I can see the commits were made before 20 days so this contribution is not falling in our guidelines. However, you can use #blog tag and write about your project using the Blog Category.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thank you for your review, @codingdefined!

So far this week you've reviewed 6 contributions. Keep up the good work!

Congratulations @skoda091! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :

You made your First Vote

Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word STOP

Do you like SteemitBoard's project? Then Vote for its witness and get one more award!

Congratulations @skoda091! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!