MCPcopy Create free account
hub / github.com/firebase/quickstart-js / toggleSignIn

Function toggleSignIn

auth/customauth.ts:35–57  ·  view source on GitHub ↗

* Handle the sign in button press.

()

Source from the content-addressed store, hash-verified

33 * Handle the sign in button press.
34 */
35function toggleSignIn() {
36 if (auth.currentUser) {
37 signOut(auth);
38 } else {
39 const token = tokenTextArea.value;
40 if (token.length < 10) {
41 alert('Please enter a token in the text area');
42 return;
43 }
44 // Sign in with custom token generated following previous instructions.
45 signInWithCustomToken(auth, token).catch(function (error) {
46 // Handle Errors here.
47 const errorCode = error.code;
48 const errorMessage = error.message;
49 if (errorCode === 'auth/invalid-custom-token') {
50 alert('The token you provided is not valid.');
51 } else {
52 console.error(error);
53 }
54 });
55 }
56 signInButton.disabled = true;
57}
58
59/**
60 * initApp handles setting up UI event listeners and registering Firebase auth listeners:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected