Steps for setting up a "forgot password" route with TypeScript in AWS Cognito Userpool

Currently, I am working on setting up a forgot-password route for my typescript project with AWS Cognito. The code below shows my initial implementation, but I encountered an error message

Contact administrator to reset password.
Is there a way to create a route where confirmed users can directly view or reset their passwords?

import AmazonCognitoIdentity from 'amazon-cognito-identity-js';

const UserPoolId = ************;
const ClientId = ************;
const region = ************

const config = {region: region }

export const resetPassword = async (req, res) => {
    try {
        const { username } = req.body;

        const poolData = {
            UserPoolId: ************,
            ClientId: ************,
          };
          
        const userPool = new AmazonCognitoIdentity.CognitoUserPool(poolData);

        const userData = {
            Username: username,
            Pool: userPool,
          };

        const cognitoUser = new AmazonCognitoIdentity.CognitoUser(userData);

        
        cognitoUser.forgotPassword({
            onSuccess: (data) => {
                console.log(data)
                res.status(200).json({ message: "Password Reset"});
            },
            onFailure: (err) => {
                console.log('ERR:', err)
                res.status(401).json({ message: "Password Not Reset", error: err.message});
            },
        })
    }
    catch (err) {
        console.log("FAILED")
        console.log("Error"+ err.message)
        res.status(500).json({ message: "Password Not Reset", error: err.message});
    }
  };

I am exploring the possibility of allowing users to either directly reset their passwords through this route or receive a confirmation email with a code for resetting their password. Does AWS Cognito User Pools support this flow?

Your help and guidance would be greatly appreciated!

Answer №1

The solution was ultimately found to be the lack of proper configuration in the messaging settings of AWS Cognito UI. To prevent this issue in the future, it is important to remember to go to User Pools -> User Pool -> Messaging -> Email and adjust the settings to allow for sending emails containing password reset codes.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Inconsistencies in AngularJS ng-checked functionality

Currently, I am utilizing angularjs in conjunction with an edit view for a form. My goal is to bind the values that were previously used. Below is the code/HTML snippet that I am working with. In addition to angularjs, I am also implementing typescript fol ...

I'm having trouble accessing my namespace in TypeScript because it hasn't been properly

After obtaining Visual Studio Community 2015 along with Node.js Tools, I decided to create a "Blank Node.js Console Application" Typescript project. Within this project, I added another TypeScript file named TypeScript1.ts. In this file, I defined the fol ...

Error message 'Not Found' is displayed for all routes except for / when using Laravel 5.1 on an AWS EC2 instance

I am currently in the process of setting up a Laravel 5.1 project on EC2 (AWS). After installing a LAMP stack (PHP 5.6) and Composer, everything appears to be functioning correctly. I was able to successfully run migrations for the Laravel app. However, wh ...

Bringing together projects utilizing varying Typescript versions within Visual Studio 2015

When working with VS2015-SP2, imagine a solution that contains two typescript projects. One project is using version 1.5 and the other is using version 1.7. How will the compiler handle this situation? ...

Error message: "The overload signature does not match the function implementation in Typescript class"

Below is the class that I have created: export class MyItem { public name: string; public surname: string; public category: string; public address: string; constructor(); constructor(name:string, surname: string, category: string, address?: ...

The API for GridOptions in Angular4's ag-Grid is not defined

Currently, I am utilizing the complimentary Version of ag-Grid within my Angular 4 Application. In this code snippet below, my intention is to automatically resize the grid within the constructor: constructor(private modalService: NgbModal) { this.gri ...

Angular application displays a 404 error page when deployed on an AWS EC2 instance

REVISED VERSION I recently created an Angular app and connected it to a REST API developed in Golang, both of which are hosted on the same AWS EC2 instance. My domain on GoDaddy is pointing to the AWS server using its IP address (A record), and I have upl ...

Tips for implementing filters in Angular2 without using the package field in the console

I am currently experiencing an issue with a filter field in my code. The filter works fine when all the package data is present, however, some items do not have a package field. As a result, I need to filter based on the package name but I am encountering ...

Unlocking new perspectives with a click

Currently exploring Angular development, I have encountered a question here but couldn't find the solution I was looking for. I am seeking suggestions and ideas on how to approach this issue. Essentially, my HTML includes buttons like the ones shown ...

Deactivate the click functionality for an element located within a division using Angular and Typescript

Currently, I am working on a web development project using Angular/Typescript. I am searching for an efficient method to apply the (click) event only to a specific division and not to some selected elements within it. For instance, let's take this d ...

Guide to adding information to a table with the help of an "interface" in Angular 6 and utilizing Typescript

Looking for some guidance with Angular as I am just starting out. I am currently trying to send an API request in angular 6 using Typescript. However, I am facing difficulties when it comes to adding data to a table. Check out my code on: Codepen In my p ...

Strategies for setting the output value for a defined generic type

Is there a way to create a function that accepts optional properties common across different types, while also requiring specific properties based on the generic type passed in? type Diff<T, U> = T extends U ? never : T type DiffTypes<T, U> = ...

Something went wrong in the prerender.ts file at line 7. The error message is indicating that it cannot locate the module './dist-prerender/main.bundle'

Encountering an error while compiling the Angular code for prerendering: ERROR in prerender.ts(7,62): error TS2307: Cannot find module './dist-prerender/main.bundle' npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] b ...

Beautiful ExpressionChangedAfterItHasBeenCheckedError

I need your help Input field where I can enter a Student email or IAM, which will be added to a string array List displaying all the students I have added, using a for loop as shown below Delete button to remove a student from the array The list has a sp ...

Retrieve the enum instance based on the specified type within a generic function

In this simplified example, we have a concept of tags, each defined by a single character. The "Flags" object accumulates these values based on an enum. The goal is to make the source code explicit, concise, easily refactorable, compiler-verified, and ensu ...

Idiosyncratic TypeScript behavior: Extending a class with comparable namespace structure

Lately, I've been working on creating a type library for a JavaScript written library. As I was defining all the namespaces, classes, and interfaces, I encountered an error TS2417 with some of the classes. I double-checked for any issues with method o ...

Leveraging property information for a dropdown field

In my index.tsx file, I am fetching data that I pass to the component FormOne. This allows me to access the data in FormOne using props.data const [data, setData] = useState([]); ... return ( ... <FormOne data={data} /> ); I am looking to ...

Utilizing client extension for Postgres with Prisma to activate RLS: A step-by-step guide

Recently, I attempted to implement client extension as advised on Github. My approach involved defining row level security policies in my migration.sql file: -- Enabling Row Level Security ALTER TABLE "User" ENABLE ROW LEVEL SECURITY; ALTER TABLE ...

Utilizing JSON data within a separate TypeScript function or within the ngOnInit lifecycle hook after successfully retrieving the data

I'm new to Angular and have a simple question. In my code, I have the following: public jsonDataResult: any; private getUrl = "../assets/data_3.json"; getScoreList(){ this.http.get(this.getUrl).subscribe((res) => { this.jsonDat ...

Version 8.0.37 of MySQL resulted in a significant memory leakage issue

Just wanted to share a quick PSA for those using MySQL 8.0.37 and dealing with a pesky memory leak issue. We're running Amazon MySQL for RDS and upgraded from 8.0.28 to 8.0.37, only to be hit with a major memory leak problem. Freeable memory was decr ...