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

🐛 Bug Report: #1575

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

🐛 Bug Report: #1575

justinelut opened this issue Dec 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@justinelut
Copy link

justinelut commented Dec 24, 2024

👟 Reproduction steps

install appwrite and expo for react native development

👍 Expected behavior

const createEmailToken = useCallback(async (email: string): Promise => {
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 => {
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

👎 Actual Behavior

Image while sending an email am getting this screen short rather than the otp token so that i can use it for verification

🎲 Appwrite version

Version 1.6.x

💻 Operating system

Linux

🧱 Your Environment

No response

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

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@justinelut justinelut added the bug Something isn't working label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant