addCustomField function

String addCustomField({
  1. required Entry authDatabase,
  2. required String username,
  3. required String customFieldName,
  4. required dynamic customFieldValue,
})

Implementation

String addCustomField({
  required Entry authDatabase,
  required String username,
  required String customFieldName,
  required dynamic customFieldValue,
}){
  DbObject? account = _getAccount(
    authDatabase: authDatabase,
    username: username,
  );
  if(account == null){
    throw "No account found asociated with the username $username.";
  }else{
    if(customFieldName == "roles" || customFieldName == "password" || customFieldName == "username" || customFieldName == "accessTokens"){
      throw "$customFieldName cannot be overriden";
    }else{
      account.insert(
        key: customFieldName,
        value: customFieldValue,
      );
      return "Added $customFieldName succesfully.";
    }
  }
}