createAccount method
Implementation
@override
Future<void> createAccount(Map<String, dynamic> createUserData) async {
logger.finest('createAccount($createUserData)');
// 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 !!!');
}
// secret
String secret = createUserData['secret'] ?? '';
if (secret.isEmpty) {
secret = HycopUtils.genUuid(includeDash: false);
createUserData['secret'] = secret;
}
String mid = 'user=$userId';
createUserData['mid'] = mid;
// create account
logger.finest('createAccount($createUserData)');
await HycopFactory.dataBase!.createData('hycop_users', mid, createUserData).catchError((error,
stackTrace) =>
throw HycopUtils.getHycopException(error: error, defaultMessage: 'loginByEmail Error !!!'));
logger.finest('createAccount($createUserData) success');
}