server/src/Entity/authentication.js
/**
    * Method to request the Password generate Token.
    * @returns {Promise<Boolean>}
    */
Method to request the Password generate Token.
@returns {Promise}
Method to request the Password generate Token . @returns { Promise }
requestPasswordChangeToken(isProduction) {
      return new Promise((resolve, reject) => {
         const token = generator.generateRandomToken(8);
         const url = (isProduction) ? constants.PASSWORD_CHANGE_URL_PROD : constants.PASSWORD_CHANGE_URL_DEV;
         const emailMessage = constants.PASSWORD_CHANGE_MESSAGE.replace("%l", url + token);
         notificationManager.sendEmail(this._emailId, emailMessage, "Password Change Link.").then(() => {
            database.runSp(constants.SP_GENERATE_AND_VALIDATE_PASSWORD_TOKEN,
               [this._emailId, token, 0, false]).then(_resultSet => {
               const result = _resultSet[0][0];
               if (validators.validateUndefined(result)) {
                  resolve(result);
               } else {
                  result({"id": -1});
               }
            }).catch(err => {
               printer.printError(err);
            });
         }).catch(err => {
            printer.printError(err);
            reject(err);
         });
      });
   }
requestPasswordChangeToken ( isProduction ) { return new Promise ( ( resolve , reject ) => { const token = generator . generateRandomToken ( 8 ) ; const url = ( isProduction ) ? constants . PASSWORD_CHANGE_URL_PROD : constants . PASSWORD_CHANGE_URL_DEV ; const emailMessage = constants . PASSWORD_CHANGE_MESSAGE . replace ( "%l" , url + token ) ; notificationManager . sendEmail ( this . _emailId , emailMessage , "Password Change Link." ) . then ( ( ) => { database . runSp ( constants . SP_GENERATE_AND_VALIDATE_PASSWORD_TOKEN , [ this . _emailId , token , 0 , false ] ) . then ( _resultSet => { const result = _resultSet [ 0 ] [ 0 ] ; if ( validators . validateUndefined ( result ) ) { resolve ( result ) ; } else { result ( { "id" : - 1 } ) ; } } ) . catch ( err => { printer . printError ( err ) ; } ) ; } ) . catch ( err => { printer . printError ( err ) ; reject ( err ) ; } ) ; } ) ; }
Method to request the Password generate Token.
Method to request the Password generate Token .