Web Developer
As i am sign in, basically the function is setup to create a session using account.createEmailPasswordSession(email, password);
export const Signin = async (email: string, password: string): Promise<Models.Session> => {
try {
const session: Models.Session = await account.createEmailPasswordSession(email, password);
return session;
} catch (error: unknown) {
console.error(error);
if (error instanceof Error) {
throw new Error(error.message);
} else {
throw new Error('An Unknown error occurred');
}
}
}
And now we have a session connected with the email and password for the user which can be seen in the appwrite dashboard also.
Now we can call the methods realted to the account like account.get and account.getsession('current') and all those methods will work fine.
Using these methods on account object we need to check on the app that if the user is logged in or not, we can not use the global state that we had set because refresing the app will clear those states.