123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
-
- //Get elements
-
- const txtEmail = document.getElementById('InputEmail1');
- const txtPassword = document.getElementById('InputPassword1');
- const btnLogin = document.getElementById('btnLogin');
- const btnSignUp = document.getElementById('btnSignUp');
- const btnLogout = document.getElementById('btnLogout');
-
- // Add login event
- btnLogin.addEventListener('click', e => {
- // Get email and pass
- const email = txtEmail.value;
- const pass = txtPassword.value;
- const auth = firebase.auth();
- // Sign in
- const promise = auth.signInWithEmailAndPassword(email, pass);
- promise.catch(e => console.log(e.message));
- promise.then(function (user) {
- // success
- console.log("Email: " + user.email);
- window.location.href = "notizenEintrag.html";
- })
- });
-
- // Add signup event
- btnSignUp.addEventListener('click', e => {
- // Get email and pass
- const email = txtEmail.value;
- const pass = txtPassword.value;
- const auth = firebase.auth();
- // Sign in
- const promise = auth.createUserWithEmailAndPassword(email, pass);
- promise.catch(e => console.log(e.message));
- promise.then(function (user) {
- // success
- console.log("Email: " + user.email);
- window.location.href = "notizenEintrag.html";
- })
- alert("SignUp gedrückt");
-
- });
-
- btnLogout.addEventListener('click', e => {
- firebase.auth().signOut();
-
- });
|