Hello everyone, I'm facing an issue in my project, called 401 Unauthorized AppwriteException: User (role: guests) missing scope (account, I'm appwite for backend as a servvice. when I'm creating an new account it will succussfully creates buut when I'm trying to LOGIN it dos'nt login . But if i try to go manually on Home page the i can go even i can create a post its working, and storage is also working but not with loggin
import { ID, Query } from "appwrite"; import { appwriteConfig, account, databases, storage, avatars } from "./config"; import { IUpdatePost, INewPost, INewUser, IUpdateUser } from "@/types"; export async function createUserAccount(user: INewUser) { try { const newAccount = await account.create( ID.unique(), user.email, user.password, user.name ); if (!newAccount) throw Error; const avatarUrl = avatars.getInitials(user.name); const newUser = await saveUserToDB({ accountId: newAccount.$id, name: newAccount.name, email: newAccount.email, username: user.username, imageUrl: avatarUrl, }); return newUser; } catch (error) { console.log(error); return error; } } export async function signInAccount(user: { email: string; password: string }) { try { const session = await account.createEmailSession(user.email, user.password); return session; } catch (error) { console.log(error); } } export async function saveUserToDB(user: { accountId: string; name: string; email: string; imageUrl: URL; username?: string; }) { try { const newUser = await databases.createDocument( appwriteConfig.databaseId, appwriteConfig.userCollectionId, ID.unique(), user ); return newUser; } catch (error) { log(error) } } export async function getAccount() { try { const currentAccount = await account.get(); return currentAccount; } catch (error) { console.log(error); } } export async function getCurrentUser() { try { const currentAccount = await getAccount(); if (!currentAccount) throw Error; const currentUser = await databases.listDocuments( appwriteConfig.databaseId, appwriteConfig.userCollectionId, [Query.equal("accountId", currentAccount.$id)] ); if (!currentUser) throw Error; return currentUser.documents[0]; } catch (error) { console.log(error); return null; } }
Recommended threads
- Why does this happen?
`AppwriteException: general_argument_invalid, Invalid `secret` param: Value must be a valid string and at least 1 chars and no longer than 256 chars (400)` the...
- Database Write Limits hit
Hello Appwrite Admins, I'm a GitHub Education user, and about a week ago, my database was really badly optimized, resulting in about 600k writes in a single day...
- Help: Domain krtrim.tech Blocked on Fast...
Hi, I'm trying to add my domain krtrim.tech (and subdomain) in Appwrite, but I'm getting this error: Failed to add domain to Fastly: {"msg":"Bad request","deta...