@@ -24,7 +24,7 @@ import Grid from '@material-ui/core/Grid';
2424import CustomSnackbar from "../components/custom_snackbar" ;
2525import Banner from '../components/banner/banner' ;
2626import OtpInput from 'react-otp-input' ;
27- import { handleThirdPartyProvidersVerbiage } from '../utils' ;
27+ import { handleErrorResponse , handleThirdPartyProvidersVerbiage } from '../utils' ;
2828
2929import styles from './login.module.scss'
3030import "./third_party_identity_providers.scss" ;
@@ -605,21 +605,22 @@ class LoginPage extends React.Component {
605605 let { user_name} = this . state ;
606606 user_name = user_name ?. trim ( ) ;
607607
608+ if ( ! user_name ) {
609+ this . showAlert (
610+ 'Something went wrong while trying to resend the verification email. Please try again later.' ,
611+ 'error' ) ;
612+ return ;
613+ }
614+
608615 resendVerificationEmail ( user_name , this . props . token ) . then ( ( payload ) => {
609616 this . showAlert (
610617 'We\'ve sent you a verification email. Please check your inbox and click the link to verify your account.' ,
611618 'success' ) ;
612619 } , ( error ) => {
613- let { response, status} = error ;
614- if ( status === 412 ) {
615- const { errors} = response . body ;
616- const allErrors = Object . values ( errors ?? { } )
617- ?. flat ?. ( )
618- ?. join ( ', ' ) || '' ;
619- this . showAlert ( allErrors , 'error' ) ;
620- return ;
621- }
622- this . showAlert ( 'Oops... Something went wrong!' , 'error' ) ;
620+ handleErrorResponse ( error , ( title , messageLines , type ) => {
621+ const message = ( messageLines ?? [ ] ) . join ( ', ' )
622+ this . showAlert ( `${ title } : ${ message } ` , type ) ;
623+ } ) ;
623624 } ) ;
624625 }
625626
0 commit comments