firebase / firebase/quickstart-js

Adapted quickstart email-password hangs on any usage of firebase.auth() attributes or functions

Open
#449 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.4k
Forks
3.7k
Avg merge
2d 13h
Merged PRs (30d)
6

Description

Title pretty much says it all. I had no trouble using these functionalities in Swift, but I'm struggling to use Auth in Javascript so I’m guessing I'm missing something simple. Everything after my "if (auth.currentUser)" isn't running in login_credentials(), and if I remove that check none of the following alerts or logs appear either in my signInWithEmailAndPassword() call. Thanks in advance.

Here is my index.html:

```html


h1 {text-align: center;}
h2 {text-align: center;}
h3 {text-align: center;}
form {text-align: center;}


Endurance Database Access




Endurance Database Access


Log In









Log In

Don't have an account? Sign up now


Sign Up









Sign Up

```
and here is the section of my index.js relating to sign in (config values hidden for privacy):

```js
require("firebase/app");

require("firebase/auth");
require("firebase/firestore");
const firebaseConfig = {
apiKey: "",
authDomain: "",
databaseURL: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: "",
measurementId: ""
};

firebase.initializeApp(firebaseConfig);
const auth = firebase.auth();

function login_credentials() {
var email = document.getElementById("email").value;
var password = document.getElementById("password").value;
if (auth.currentUser) {
// [START signout]

auth.signOut();
// [END signout]
}
alert("test") //doesn't show up unless above the if statement

auth.signInWithEmailAndPassword(email, password)
.then(function(firebaseUser) {
alert(firebaseUser.credential);
})
.catch(function(error) {
var errorCode = error.code;
var errorMessage = error.message;
window.alert("alert: " + errorCode + ": " + errorMessage);
console.log("error: " + errorCode + ": " + errorMessage);
});

}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.