Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(users): implement api route to add new user to cognito #615

Merged
merged 2 commits into from
Feb 29, 2024

Conversation

nganphan123
Copy link
Contributor

Welcome to PrivacyPal! 👋

Fixes: #607

Description of the change:

Add new API route to add user to cognito under CLIENT group.

Motivation for the change:

We need this API for the client registration form. Professionals can add new clients given their username and email. It's not feasible to let professionals create usernames for clients, but Cognito doesn't allow changing this unless we create new user pool. Also, removing username from registration will requires changes in data schema as email now works as user identifier not username. I think we should keep the current process (letting professionals create usernames for clients) for the sake of upcoming peer testing.

How to test

PUT /api/clients

Request body required:

"username": new client username
"email": new client email

Request: http://localhost:3000/api/clients
{
    "username": "ngan-test-new-user",
    "email": "jill01009@gmail.com"
}
Response: 
{
    "data": {
        "message": "User successfully added to user pool"
    }
}

@nganphan123 nganphan123 added the area/back-end Back-end work label Feb 28, 2024
@nganphan123 nganphan123 added this to the Term 2 Week 6 milestone Feb 28, 2024
@nganphan123 nganphan123 self-assigned this Feb 28, 2024
@tthvo tthvo added the feat New feature or request label Feb 28, 2024
const body: RequestBody = await req.json();

// TODO: Consider removing this code and implement the check in middleware
const loggedinUser = await getLoggedInUser();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added new issue: #620

Copy link
Contributor

@connordoman connordoman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work Ngan! Thanks for getting docs done too

@tthvo tthvo force-pushed the gh-607-api-route-to-add-new-client-to-cognito branch from eee4182 to 685578e Compare February 29, 2024 19:46
@tthvo tthvo merged commit fd8a432 into develop Feb 29, 2024
14 checks passed
@tthvo tthvo deleted the gh-607-api-route-to-add-new-client-to-cognito branch February 29, 2024 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/back-end Back-end work feat New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants