Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

📚 Documentation: #1574

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

📚 Documentation: #1574

justinelut opened this issue Dec 24, 2024 · 0 comments
Labels
documentation Improvements or additions to documentation

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant