addCustomField function
String
addCustomField(
{ - required Entry authDatabase,
- required String username,
- required String customFieldName,
- 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.";
}
}
}