All files / events OnForgotPassword.ts

88.89% Statements 8/9
100% Branches 0/0
100% Functions 2/2
88.89% Lines 8/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  3x 3x             3x   3x 3x 3x 3x             3x  
import { IAuthenticationResult } from '../types';
import OnCheckSession from './OnCheckSession';
import { Auth } from 'aws-amplify';
 
/**
 * Start the change password flow with AWS Cognito, followed by the {@link OnConfirmPassword}
 * @param input See {@link ICognitoUserVariables}
 * @returns See {@link IAuthenticationResult}
 */
export const OnForgotPassword = async (
  username: string
): Promise<IAuthenticationResult> => {
  try {
    const result = await Auth.forgotPassword(username);
    return OnCheckSession(result);
  } catch (error) {
    // if (__DEV__) console.log(error);
    return OnCheckSession(error);
  }
};
 
export default OnForgotPassword;