Hey π
I'm not able to create a User und send him a verification mail.
Always receive /v1/account/verification 401 (Unauthorized)
there is no old session, cause i get /v1/account/sessions/current 401 (Unauthorized) too
just using the signIn as documented with account.get() results in
AppwriteException: User (role: guests) missing scope (account)
Can you provide the code you're using?
sure 1 sec
appwrite.ts
import {Client, Databases, Account, Avatars} from 'appwrite';
import {environment} from '@environment/environment';
export const client = new Client();
client
.setEndpoint('<endpoint>') // blanked but set in my Code
.setProject(environment.projectId)
.setLocale('de-DE');
export const account: Account = new Account(client);
export const databases: Databases = new Databases(client);
export const avatars: Avatars = new Avatars(client);
export { ID } from 'appwrite';
auth.service.ts
async signIn(email: string, password: string) {
try {
await account.deleteSession('current');
const session = account.createEmailPasswordSession(email, password);
session.then((response) => {
console.info('Session created', response);
}).catch((error) => {
console.error('Session creation failed', error);
})
const user = await account.get();
if (!user) {
console.error('User not found');
this.toast.error('User not found');
return;
}
} catch (err) {
console.error(err);
throw new Error;
}
}
async signUp(email: string, password: string, username: string) {
try {
const newAccount = await account.create(ID.unique(), email, password, username);
if (!newAccount) {
console.error('Account creation failed');
this.toast.error('Account creation failed');
return;
}
const avatarUrl = avatars.getInitials(username);
await this.signIn(email, password);
// Tried with verification here
// await account.createVerification('https://environment.baseUrl/verify');
const newUser = await databases.createDocument(
this.databaseId,
this.collectionId,
ID.unique(),
{
userId: newAccount.$id,
email,
username,
avatar: avatarUrl
}
);
return newUser;
} catch (err) {
console.error(err);
throw new Error;
}
}
tried the signUp without the signIn, just account.create -> account.createVerification
went through some posts and did alot try and error, now I'm a bit lost
After creating the account you need to create a new session so you will have to do the createEmailPasswordSession. Are you actually getting after account.deleteSession() ?
I can't remember if no current session exists does deleteSession throw and prevent the code from progressing
Removed the line and tried signIn
And?
/v1/account 401 (Unauthorized)
AppwriteException: User (role: guests) missing scope (account)
Does it tell you which method is throwing that?
Do you have a stack trace?
Can you try this?
async signIn(email: string, password: string) {
try {
const session = await account.createEmailPasswordSession(email, password);
const user = await account.get();
if (!user) {
console.error('User not found');
this.toast.error('User not found');
return;
}
} catch (err) {
console.error(err);
throw new Error;
}
}
Recommended threads
- Domain is owned by a different organizat...
Hi Appwrite team, I'm trying to add my custom domain **futlive9.com** to my project, but I'm getting the error: "Domain is owned by a different organization." ...
- CreateRow is doing ListRows on self-host...
### setup ``` appwrite 1.9.5 self-hosted bun 1.3 node-appwrite 27.1.0 ``` ### issue Im running a function on a self hosted 1.9.5 with "node-appwrite": "^27.1.0...
- Local function execution results in HTTP...
Hi all, I'm trying to develop a new function on my Ubuntu 24.04 machine running the latest version of docker. I've read through the documentation to install and...