Bijit !! Bijit-Mondal
this is my code, I want to verify the email before the user can login, but unable to do in createAccount part, how to do that and prevent unauthorized user from login
TypeScript
export const useAuth = () => {
// login user
const loginUser = async (auth) => {
try {
return await account.createEmailSession(auth.email, auth.password)
} catch (error) {
console.log(error)
throw error
}
}
// register user
const register = async (auth) => {
try {
const newAccount = await account.create(ID.unique(), auth.email, auth.password, auth.firstName+" "+auth.lastName)
if (!newAccount) {
throw Error
}
const avatarUrl = avatars.getInitials(auth.firstName + " " + auth.lastName, 200, 200)
return await saveUserToDB({
user_id: newAccount.$id,
email: newAccount.email,
first_name: auth.firstName,
last_name: auth.lastName,
avatar_url: avatarUrl,
bodhi_points: 0
})
} catch (e) {
console.log(e)
throw e
}
}
// save user to database
const saveUserToDB = async ( user) => {
try {
return await databases.createDocument(
appwriteConfig.databaseId,
appwriteConfig.userCollectionId,
ID.unique(),
user,
)
} catch (e) {
console.log(e)
throw e
}
}
return {
loginUser,
register,
saveUserToDB,
}
}
TL;DR
Developers want to verify user email before login but are facing issues with the process. To prevent unauthorized access, implement email verification during the account creation step before allowing login. Recommended threads
- Query Appwrite
Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?
- Different appwrite IDs are getting expos...
File_URL_FORMAT= https://cloud.appwrite.io/v1/storage/buckets/[BUCKET_ID]/files/[FILE_ID]/preview?project=[PROJECT_ID] I'm trying to access files in my web app...
- Invalid document structure: missing requ...
I just pick up my code that's working a week ago, and now I got this error: ``` code: 400, type: 'document_invalid_structure', response: { message: 'Inv...