Skip to content

Commit

Permalink
Merge pull request #18 from andrenavas/sandra2
Browse files Browse the repository at this point in the history
Refactorización de funciones internas login y google (loginFirebase, …
  • Loading branch information
andrenavas authored Apr 14, 2023
2 parents e93dc26 + 084b07c commit 706a910
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import { auth } from './index.js';

export const loginEmail = (email, password) => {
signInWithEmailAndPassword(auth, email, password)
signInWithEmailAndPassword(auth, email.value, password.value)
.then(() => {

})
Expand Down
29 changes: 18 additions & 11 deletions src/templates/login.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import { loginEmail, loginGoogle } from '../lib/auth.js';
// eslint-disable-next-line no-shadow

const loginFirebase = (email, password) => {
const loginPrevent = (e) => {
e.preventDefault();
loginEmail(email, password);
};
return loginPrevent;
};

const googleFirebase = () => {
loginGoogle();
};
export function login(navegacion) {
const section = document.createElement('section');
if (sessionStorage.getItem('user')) {
Expand Down Expand Up @@ -62,23 +74,18 @@ export function login(navegacion) {
navegacion('/registro');
});

// Evento del botón Iniciar Sesión
// Evento del botón Iniciar Sesiòn

const btnInicio = section.querySelector('#btnInicio');
const password = section.querySelector('#password');
const email = section.querySelector('#email');

btnInicio.addEventListener('click', () => {
const password = section.querySelector('#password').value;
const email = section.querySelector('#email').value;
loginEmail(email, password);
});
btnInicio.addEventListener('click', loginFirebase(email, password));

// Evento del botón Iniciar Sesión con Google
// Google inicio

const btnGoogle = section.querySelector('#btnGoogle');

btnGoogle.addEventListener('click', () => {
loginGoogle();
});

btnGoogle.addEventListener('click', googleFirebase);
return section;
}

1 comment on commit 706a910

@vercel
Copy link

@vercel vercel bot commented on 706a910 Apr 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

mascoteando – ./

mascoteando-git-main-andrenavas.vercel.app
mascoteando.vercel.app
mascoteando-andrenavas.vercel.app

Please sign in to comment.