[Vuejs]-Trying to create a login with mongodb

0👍

While trying to reformat your question to remove the HTML, I noticed that you have several unmatched parentheses.

You have an extra line }); in your code that is blocking your login function from getting to the if statement.

Correct indentation can help you spot errors like this.

Here is the corrected code with the line removed.

const logindetails = new Vue({
  el: '#logindetails',
  data: {
    errors: [],
    email: "",
    passwordInput: ""
  },

  methods: {
    login: function () {
      var account = db.collection('users')(userdetails.email === userdetails.email &&
        userdetails.passwordInput === userdetails.password) ? userdetails : null;
      if (account) {
        window.location.href = "welcomepage.html?email=" + account.email;
      } else {
        alert("Email/Password has not been identified.");
      }
    }
  }
});

Here is the original code, with a comment beside the problem line

const logindetails = new Vue({
  el: '#logindetails',
  data: {
    errors: [],
    email: "",
    passwordInput: ""
  },

  methods: {
    login: function () {
      var account = db.collection('users')(userdetails.email === userdetails.email &&
        userdetails.passwordInput === userdetails.password) ? userdetails : null;
    });  //<-- looks wrong, stops 'login' function


if (account) {
  window.location.href = "welcomepage.html?email=" + account.email;
} else {
  alert("Email/Password has not been identified.");
}
    }
}
});

Leave a comment