!Original post
Rank 1: Thread
when creating an account I use following methods:
Future<void> register(String email, String password, String username) async {
final user = await account.create(userId: ID.unique(), email: email, password: password);
await account.createEmailPasswordSession(email: email, password: password);
final userId = UserID(user.$id);
await _createUsername(userId, username);
await _createUser(userId, username);
await getAccount(); // push to stream
}
Future<void> _createUser(UserID userId, String username) async {
// try {
await db.createRow(
databaseId: AppwriteBootstrap.databaseId,
tableId: AppwriteBootstrap.usersCollectionId,
rowId: userId.value,
data: {
'bio': null,
'photoUrl': null,
'username': username,
},
permissions: [
Permission.read(Role.users()),
Permission.update(Role.user(userId.value)),
Permission.delete(Role.user(userId.value)),
],
);
//} catch (_) {
return;
//}
}
Future<Row> _createUsername(UserID userId, String username) async {
return await db.createRow(
databaseId: AppwriteBootstrap.databaseId,
tableId: AppwriteBootstrap.usernamesCollectionId,
rowId: username,
data: {
'user': null
},
permissions: [
Permission.read(Role.any()),
Permission.update(Role.user(userId.value)),
Permission.delete(Role.user(userId.value)),
],
);
}
and _createUsername does work properly, creating the row with the username as id parameter. But when creating the user informations in _createUser, linking it to its relation in usernames, I get the missing authentication error. Same scopes, same restrictions in cloud, everything should be smooth.
If you need me to provide more specific info, @tell me.
Summary
Developers are experiencing a permission failure when linking user information to usernames in a registration process. Despite having the same restrictions and scopes in the cloud, an authentication error occurs. The 'missing authentication error' seems to be due to user permissions when creating user information.
**Solution:** Verify and update the permissions in the `_createUser` method to ensure they are correctly set up to link user information to usernames. Double-check permissions related to reading, updating, and deleting roles to prevent any authentication errors.