after reading what i could find on sessions (https://appwrite.io/docs/references/cloud/models/session) and account (https://appwrite.io/docs/references/cloud/client-react-native/accountI), i seem to understand that:
- $id is the session id
- the userId is the user id... however, when i run account.get() i seem to get the session id for both of those. there are no id's that match in my database atleast,
i have it setup like this:
client
.setEndpoint(config.endpoint)
.setProject(config.projectId)
.setPlatform(config.platform);
const account = new Account(client);
export async function getCurrentUser() {
try {
const user = await account.get();
console.log('Current user fetched:', user);
return user;
} catch (error) {
console.log('No active session:', error);
return null;
}
}
this returns something like this:
Current user: {"$createdAt": "2025-03-18T07:10:17.842+00:00", "$id": "[redacted]dc362c", "$updatedAt": "2025
-03-19T07:14:11.225+00:00", "accessedAt": "2025-03-19T07:14:11.220+00:00", "email": "quan@example.com", "emailVerification": tr
ue, "labels": ["admin"], "mfa": false, "name": "quan", "passwordUpdate": "2025-03-18T07:10:17.839+00:00", "phone": "", "phoneVe
rification": false, "prefs": {}, "registration": "2025-03-18T07:10:17.839+00:00", "status": true, "targets": [{"$createdAt": "202
5-03-18T07:10:17.896+00:00", "$id": "[redacted]5ebed2", "$updatedAt": "2025-03-18T07:10:17.896+00:00", "expired": false, "ide
ntifier": "junker@example.com", "name": "", "providerId": null, "providerType": "email", "userId": "[redacted]dc362c"}]}
the user id that i can see in the database (or collection) is "[redacted]2eefbb"
am i understanding the documentation wrong? am i reading the returned data wrong perhaps? i dont quite understand what is at work here, as it seem other users on the internet are just getting their id'd like they want.
any help is appreciated
it seems like i have indeed misunderstood. what is happening is that i am getting the user id from a schema or document, which is the same user as the one in auth. however, the id's arent the same, and i am ofcourse checking up on the auth id, against the other id, which would never be the same
Recommended threads
- All My Project is Gone
Hello everyone, please help. Why have all my projects suddenly disappeared? I received a warning via email about one of my projects being paused. When I clicked...
- > AppwriteException: The requested servi...
When trying to read or write from my database I get the following error: > AppwriteException: The requested service is disabled. You can enable the service from...
- Courtesy limit reset for non-profit migr...
Hi Team! I'm the architect for a 501(c)(3) non-profit project (Aaria's Blue Elephant) and we just hit our Free plan Database Read limit (currently at 164%). Th...