Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

📚 Documentation: #1574

Closed
justinelut opened this issue Dec 24, 2024 · 0 comments
Closed

📚 Documentation: #1574

justinelut opened this issue Dec 24, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation duplicate This issue or pull request already exists invalid This doesn't seem right

Comments

@justinelut
Copy link

💭 Description

    setIsLoading(true);
    try {
      const emailtoken = await account.createEmailToken(ID.unique(), email, true);
      console.log('Email token sent successfully', emailtoken);
    } catch (error) {
      console.error('Failed to send email token:', error);
      throw error;
    } finally {
      setIsLoading(false);
    }
  }, []);```

  // New method to verify email token
 ``` const verifyEmailToken = useCallback(
    async (userId: string, token: string): Promise<void> => {
      setIsLoading(true);
      try {
        // Create session using the token
        const session = await account.createSession(userId, token);

        if (!session) {
          throw new Error('Failed to create session');
        }

        // Get user data after successful session creation
        const userData = await account.get();

        // Update user state
        setUser((prevUser) =>
          JSON.stringify(userData) !== JSON.stringify(prevUser) ? userData : prevUser
        );

        // Save session
        await saveSession(userData);

        console.log('Email token verified successfully');
      } catch (error) {
        console.error('Failed to verify email token:', error);
        throw error;
      } finally {
        setIsLoading(false);
      }
    },
    [saveSession]
  );``` trying to use these 2 functions to do 2 step verification in a react native application, i understand i cant use api key here so the appwrite backend sends the template for me via the configured templates, but i dont know which variables show the secret or otp and there is no clears documentation about all the variables for each template, example i tried using the otp session template the way it is in the dashboard, but am getting this below, i dont know if its parsing that is bad or am not using the correct variables, which i have tried finding the docs for and i couldnt.

![Image](https://github.com/user-attachments/assets/93b5b255-7b95-4c04-98d0-c43ba1e92a2c)



### 👀 Have you spent some time to check if this issue has been raised before?

- [x] I checked and didn't find similar issue

### 🏢 Have you read the Code of Conduct?

- [x] I have read the [Code of Conduct](https://github.com/appwrite/.github/blob/main/CODE_OF_CONDUCT.md)
@justinelut justinelut added the documentation Improvements or additions to documentation label Dec 24, 2024
@gurjeetsinghvirdee gurjeetsinghvirdee added invalid This doesn't seem right duplicate This issue or pull request already exists labels Jan 28, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
documentation Improvements or additions to documentation duplicate This issue or pull request already exists invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants