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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Bug Report: User login #8284

Open
2 tasks done
Jedidiah-Solomon opened this issue Jun 18, 2024 · 0 comments
Open
2 tasks done

馃悰 Bug Report: User login #8284

Jedidiah-Solomon opened this issue Jun 18, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Jedidiah-Solomon
Copy link

Jedidiah-Solomon commented Jun 18, 2024

馃憻 Reproduction steps

After sign up, I tried to login but it says Error logging in: Invalid `userId` param: Parameter must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char

馃憤 Expected behavior

login.html

<title>Log In</title> <script src="../dist/login.bundle.js" defer></script>

Log In

Email:
Password:
Log In

login.js
import { Client, Account } from "appwrite";

const client = new Client();
client
.setEndpoint("https://cloud.appwrite.io/v1")
.setProject("6670bced001681b60586");

const account = new Account(client);

document
.getElementById("login-form")
.addEventListener("submit", function (event) {
event.preventDefault();

const email = document.getElementById("email").value;
const password = document.getElementById("password").value;

account
  .createSession(email, password)
  .then((response) => {
    console.log("User logged in:", response);
    alert("Login successful!");

    document.getElementById("login-form").reset();

    window.location.href = "/pages/news-today.html";
  })
  .catch((error) => {
    console.error("Error logging in:", error);
    alert("Error logging in: " + error.message);
  });

});

FROM BROWSER NETWORK TAB:

Request URL:
https://cloud.appwrite.io/v1/account/sessions/token
Request Method:
POST
Status Code:
400 Bad Request
signup.html -- this was successful and user can be added to the dashboad
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Sign Up</title>
    <link rel="stylesheet" href="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/styles/signup.css" />
    <!-- Adjust path if necessary -->
    <script src="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/dist/signup.bundle.js" defer></script>
    <!-- Correct path to the bundle -->
  </head>
  <body>
    <h1>Sign Up</h1>
    <form id="signup-form">
      <label for="username">Username:</label>
      <input type="text" id="username" name="username" required /><br />
      <label for="email">Email:</label>
      <input type="email" id="email" name="email" required /><br />
      <label for="password">Password:</label>
      <input type="password" id="password" name="password" required /><br />
      <button type="submit">Sign Up</button>
    </form>
  </body>
</html>

signup.js

import { Client, Account, ID } from "appwrite";

// Initialize the Appwrite client
const client = new Client();
client
  .setEndpoint("https://cloud.appwrite.io/v1") // Set the endpoint of your Appwrite server
  .setProject("6670bced001681b60586"); // Set your project ID

// Create an Account instance
const account = new Account(client);

// Add an event listener to the signup form submission
document
  .getElementById("signup-form")
  .addEventListener("submit", function (event) {
    event.preventDefault();

    // Get the user input values
    const username = document.getElementById("username").value;
    const email = document.getElementById("email").value;
    const password = document.getElementById("password").value;

    // Create a new user account
    account
      .create(ID.unique(), email, password, username)
      .then((response) => {
        console.log("User created:", response);
        alert("User created successfully!");

        // Inform the user to check their email for verification
        alert("Please check your email for a verification link.");
        document.getElementById("signup-form").reset();
        setTimeout(() => {
          window.location.href = "/pages/login.html";
        }, 2000); // 2-second delay
      })
      .catch((error) => {
        console.error("Error creating user:", error);
        alert("Error creating user: " + error.message);
      });
  });

馃憥 Actual Behavior

I need to log in

馃幉 Appwrite version

Appwrite Cloud

馃捇 Operating system

Linux

馃П Your Environment

Web

馃憖 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?

@Jedidiah-Solomon Jedidiah-Solomon added the bug Something isn't working label Jun 18, 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