简体   繁体   中英

vue + firebase auth output console.log of auth/internal-error instead auth/invalid-password

I'm trying to test authentication of my simple vue application that using firebase, but the console.log of its error give output "auth/internal-error" instead "auth/invalid-password" when I give empty password

Firebase: An internal AuthError has occurred. (auth/internal-error).

<script setup>

import { ref } from 'vue'
import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import { useRouter } from 'vue-router'

const email = ref('')
const password = ref('')
const errMsg = ref()
const router = useRouter()
const login = () => {
    firebase
        .auth()
        .signInWithEmailAndPassword(email.value, password.value)
        .then((data) => {
        console.log('Successfully logged in!');
        router.push('/dashboard')
        })
        .catch((error) => {
            const errorCode = error.code;
            const errorMessage = error.message;   
            console.log(error.message);
        })
}

You should not allow the request with an empty password. Handle the error before, when you know it will happen.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM