Hello please help me solve this This is auth.js
TypeScript
import conf from "../conf/conf.js"
import { Client, Account, ID } from "appwrite";
export class AuthService {
client = new Client();
account;
constructor(){
this.client
.setEndpoint(conf.appwriteUrl)
.setProject(conf.appwriteProjectId)
this.account = new Account(this.client)
}
async createAccount({email, password, name}){
try {
const userAccount = await this.account.create(ID.unique(), email, password, name)
if (userAccount) {
return login({email, password})
} else {
return userAccount
}
} catch (error) {
throw error
}
}
async login({email, password}){
try {
return await this.account.createEmailSession(email, password)
} catch (error) {
throw error
}
}
async getCurrentUser(){
try {
return await this.account.get()
} catch (error) {
console.log("Appwrite service :: getCurrentUser() :: ", error)
}
return null
}
async logout(){
try {
await this.account.deleteSessions()
} catch (error) {
console.log("Appwrite service :: logout() :: ", error)
}
}
}
const authService = new AuthService()
export default authService
TL;DR
AppwriteException: User (role: guests) missing scope (account);
Developer is seeking help with solving an issue in their auth.js file. The AuthService class is missing the necessary scope for a guest user. The createAccount function seems to be calling a login function that is not defined.
Solution: Add the missing scope for the guest role in the auth.js file. Ensure the login function is properly defined and called within the createAccount function.Recommended threads
- I lost my account, only thing i have is ...
So i had this project on appwrite for my web project called Islami zindagi, but i havent used it in a while, now i tried to login, but i could not remember the ...
- Sites: Auto deploy on wrong github repos...
Hello, I have kinda with UAT(testing env) and prod env. When i pull request from dev -> uat, which stands as pre-prod environment to fully test all functionalit...
- Generate CSR
How do I generate a CSR for my domain host? They are asking me to generate one for my hoosting here on appwrite