resetPassword method

  1. @override
Future<(String, String)> resetPassword(
  1. String email
)
override

Implementation

@override
Future<(String, String)> resetPassword(String email) async {
  logger.finest('resetPassword');
  //
  // 서버의 api-url로 email정보 전송
  // => users 테이블에서 email 계정을 찾아서 (임의의)secret키 set, userId를 get
  // => smtp로 email 계정으로 secret키 및 userId를 전송 (ex: https://www.examples.com/resetPasswordConfirm?userId=xxx&secret=yyy )
  //
  logger.finest('resetPassword(email:$email)');
  final getUserDataList = await HycopFactory.dataBase!
      .simpleQueryData('hycop_users', name: 'email', value: email, orderBy: 'name')
      .catchError((error, stackTrace) => throw HycopUtils.getHycopException(
          error: error, defaultMessage: 'not exist account(email:$email) !!!'));
  if (getUserDataList.isEmpty) {
    logger.severe('getData error !!!');
    throw const HycopException(message: 'getData failed !!!');
  }
  var getUserData = getUserDataList[0]; // exist only-one
  final userModel = UserModel(userData: getUserData);
  if (userModel.accountSignUpType != AccountSignUpType.hycop) {
    return ('', '');
  }
  String secret =
      HycopUtils.genUuid(includeDash: false); //const Uuid().v4().replaceAll(RegExp(r'-'), '');
  getUserData['secret'] = secret;
  await HycopFactory.dataBase!
      .setData('hycop_users', 'user=${getUserData['userId']}', getUserData)
      .catchError((error, stackTrace) =>
          throw HycopUtils.getHycopException(error: error, defaultMessage: 'setData Error !!!'));
  return (userModel.userId, secret);
}