createAccount function
Implementation
Future<void> createAccount({
required String username,
required String password,
})async{
String uuid = uniqueAlphanumeric(tokenLength: 40);
Account newAccount = Account(
uuid: uuid,
username: username,
password: password,
accessTokens: [],
roles: [],
);
//Create account if it doesn't exist
Account? existingAccount = await getAccount(
username: username,
password: password,
);
if(existingAccount == null){
//Create Account
File outputFile = File("${authFolder.path}/$uuid.json");
await outputFile.create(recursive: true);
await outputFile.writeAsString(newAccount.json());
}else{
throw "Username already exists";
}
}