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
- Collections list not showing up when try...
I'm trying to create new relationship attribute but both one way and two way relationship is not showing up collections list to connect with my relationship att...
- I have try to use the appwrite in to the...
Invalid Origin. Register your new client (oailedjdbkhlkakmnnapoonllbnfmfij) as a new Web (Chrome Extension) platform on your project console dashboard
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...