File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed
Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ const firebaseConfig = {
2+ apiKey :"YOUR_KEY" ,
3+ authDomain :"YOUR_DOMAIN" ,
4+ projectId :"YOUR_ID"
5+ } ;
6+
7+ firebase . initializeApp ( firebaseConfig ) ;
8+
9+ const auth = firebase . auth ( ) ;
10+ const db = firebase . firestore ( ) ;
11+
12+ function login ( ) {
13+
14+ const e = document . getElementById ( "email" ) . value ;
15+ const p = document . getElementById ( "password" ) . value ;
16+
17+ auth . signInWithEmailAndPassword ( e , p )
18+ . catch ( err => {
19+ document . getElementById ( "authMsg" ) . innerText = err . message ;
20+ } ) ;
21+
22+ }
23+
24+ function logout ( ) {
25+ auth . signOut ( ) ;
26+ }
27+
28+ auth . onAuthStateChanged ( user => {
29+
30+ if ( user ) {
31+
32+ document . getElementById ( "loginSection" ) . style . display = "none" ;
33+ document . getElementById ( "mainApp" ) . style . display = "block" ;
34+
35+ } else {
36+
37+ document . getElementById ( "loginSection" ) . style . display = "block" ;
38+ document . getElementById ( "mainApp" ) . style . display = "none" ;
39+
40+ }
41+
42+ } ) ;
You can’t perform that action at this time.
0 commit comments