createAccount method

  1. @override
Future<void> createAccount(
  1. Map<String, dynamic> createUserData
)
override

Implementation

@override
Future<void> createAccount(Map<String, dynamic> createUserData) async {
  logger.finest('createAccount($createUserData)');
  // accountSignUpType
  // var accountSignUpType = AccountSignUpType.fromInt(
  //   int.parse(createUserData['accountSignUpType'].toString()),
  // );
  // userId
  String userId = createUserData['userId'] ?? '';
  if (userId.isEmpty) {
    // not exist userId ==> create new one
    userId = HycopUtils.midToKey(genMid2(ObjectType.user).replaceAll('-', ''));
    createUserData['userId'] = userId;
  }
  // email
  String email = createUserData['email'] ?? '';
  if (email.isEmpty) {
    logger.severe('email is empty !!!');
    throw HycopUtils.getHycopException(defaultMessage: 'email is empty !!!');
  }
  // password
  // String password = createUserData['password'] ?? '';
  // secret
  String secret = createUserData['secret'] ?? '';
  if (secret.isEmpty) {
    secret = HycopUtils.genUuid(includeDash: false); //const Uuid().v4().replaceAll('-', '');
    createUserData['secret'] = secret;
  }
  // create account
  logger.finest('createAccount($createUserData)');
  await HycopFactory.dataBase!
      .createData('hycop_users', 'user=$userId', createUserData)
      .catchError((error, stackTrace) => throw HycopUtils.getHycopException(
          error: error, defaultMessage: 'loginByEmail Error !!!'));
  logger.finest('createAccount($createUserData) success');
}