After countless attempts, I am still struggling to get my Firebase login function to appropriately switch the component upon signing in. I urgently need assistance with configuring my router to seamlessly transition to the next page once the sign-in process is complete.
<template>
<div class="vue-tempalte" id="regForm">
<form>
<h1 id="middle">Sign In</h1>
<div class="form-group">
<label>Email address</label>
<input type="email" id="email" v-model="email" required />
</div>
<div class="form-group">
<label>Password</label>
<input type="password" id="password" v-model="password" required />
</div>
<button type="submit" @click="login" class="button is-light" id="btn1">
Sign In
</button>
</form>
</div>
</template>
<style scoped>
</style>
<script>
import firebase from "firebase";
export default {
name: "login",
data() {
return {
email: "",
password: "",
};
},
mounted: function () {
if (firebase.auth().currentUser) this.$router.replace("/HeaderLoggedIn");
},
methods: {
login: function () {
firebase
.auth()
.signInWithEmailAndPassword(this.email, this.password)
.then((user) => {
console.log(user.user);
});
},
},
};
</script>