Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert 11 firestore a #10

Open
wants to merge 30 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
290459c
SPA
atzinmartinez Sep 28, 2022
be22f0c
Merge pull request #1 from atzinmartinez/rama_a
atzinmartinez Sep 28, 2022
c984366
comentarios no valido
atzinmartinez Sep 29, 2022
d6084a6
Registro y registro con google
atzinmartinez Sep 30, 2022
c0bd4aa
Merge pull request #3 from atzinmartinez/rama_a
atzinmartinez Sep 30, 2022
292c668
funciones userObserver, password hiden, background changes
atzinmartinez Oct 3, 2022
1deac39
Merge pull request #4 from atzinmartinez/rama_a
atzinmartinez Oct 3, 2022
6670ef8
estos cambios se tenian que subir
ElsyCaro Oct 4, 2022
05db6a8
codigo erroneo
atzinmartinez Oct 4, 2022
3b34d37
Merge branch 'main' of https://github.com/ElsyCaro/CDMX013-social-net…
ElsyCaro Oct 4, 2022
c38ddd1
Cambios para tener el main correcto
ElsyCaro Oct 4, 2022
d263b05
HU1 terminada
atzinmartinez Oct 4, 2022
bdb4f20
HU1 terminada
atzinmartinez Oct 4, 2022
cf6f7ff
Merge branch 'main' into rama_a
atzinmartinez Oct 4, 2022
c0df3d9
Merge pull request #5 from atzinmartinez/rama_a
ElsyCaro Oct 4, 2022
b59d375
Log out
atzinmartinez Oct 5, 2022
0ab0da1
Merge pull request #6 from atzinmartinez/rama_a
atzinmartinez Oct 5, 2022
747b850
se creo caja de comentarios y boton
ElsyCaro Oct 7, 2022
37c0c6a
Se agrego caja de cometarios
ElsyCaro Oct 7, 2022
95981a4
Se agrego caja de cometarios
ElsyCaro Oct 7, 2022
86a070b
Merge pull request #7 from ElsyCaro/firebase
ElsyCaro Oct 7, 2022
38332ed
Al dar click en el boton se ve reflejado lo del input en firebase
atzinmartinez Oct 7, 2022
b3aece4
Merge pull request #8 from atzinmartinez/firestore_a
ElsyCaro Oct 7, 2022
061057a
se pinta en la app
atzinmartinez Oct 11, 2022
4516aac
Merge pull request #9 from atzinmartinez/firestore_a
ElsyCaro Oct 11, 2022
3595a6a
Comentarios + css
atzinmartinez Oct 12, 2022
535af70
Merge pull request #10 from atzinmartinez/firestore_a
ElsyCaro Oct 12, 2022
baa03c0
boton borrar funcional
atzinmartinez Oct 12, 2022
76a553d
Merge pull request #11 from atzinmartinez/firestore_a
ElsyCaro Oct 12, 2022
2a6f335
Revert "boton borrar funcional"
ElsyCaro Oct 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
funciones userObserver, password hiden, background changes
  • Loading branch information
atzinmartinez committed Oct 3, 2022
commit 292c668a164fcd5b40e7f85d924f451b928aeb0f
20 changes: 16 additions & 4 deletions src/components/Login.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable max-len */
import { onNavigate } from '../main.js';
import { signWithEmailPassword } from '../firebase/auth.js';


export const Login = () => {
Expand All @@ -11,11 +12,12 @@ export const Login = () => {
const inputEmail = document.createElement('input');
const inputPassword = document.createElement('input');
const recuerdame = document.createElement('p');
const buttongoogle = document.createElement('button');

const forgotpassword = document.createElement('p');
const line = document.createElement('hr');
const notienescuenta = document.createElement('p');
const buttonnuevacuenta = document.createElement('button');
const imageGoogletwo = document.createElement('img');

titlepost.textContent = 'Postalk';
titlepost.classList = ('postalklog');
Expand All @@ -30,10 +32,10 @@ export const Login = () => {
inputEmail.classList = ('emaillogin');
inputPassword.placeholder = 'Contraseña';
inputPassword.classList = ('passwordlogin');
inputPassword.setAttribute('type', 'password');
recuerdame.textContent = 'Recordarme';
recuerdame.classList = ('recuerdame');
buttongoogle.textContent = '';
buttongoogle.classList = ('buttongoogle');

forgotpassword.textContent = '¿Olvisdaste la constraseña?';
forgotpassword.classList = ('forgotpassword');
line.classList = ('line');
Expand All @@ -42,12 +44,22 @@ export const Login = () => {
buttonnuevacuenta.textContent = 'Registrar';
buttonnuevacuenta.classList = ('buttonnuevacuenta');

imageGoogletwo.classList = ('buttongoogle');
imageGoogletwo.setAttribute('src', 'https://i.postimg.cc/tJh7mK8T/google.png');

/*botonparaacceder.addEventListener('click', () => {
let mail = inputEmail.value
let password = inputPassword.value
signWithEmailPassword(mail, password);
});*/


buttonBack.addEventListener('click', () => {
onNavigate('/');
});


div.append(titlepost, recuerdame, notienescuenta, line, forgotpassword, buttongoogle, title, inputEmail, inputPassword, button, buttonBack, buttonnuevacuenta);
div.append(titlepost, imageGoogletwo, recuerdame, notienescuenta, line, forgotpassword, title, inputEmail, inputPassword, button, buttonBack, buttonnuevacuenta);

return div;
};
Expand Down
1 change: 1 addition & 0 deletions src/components/Register.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const Register = () => {
inputEmail.classList = ('inputEmail');
inputPass.textContent = ('input');
inputPass.classList = ('inputPass');
inputPass.setAttribute('type', 'password');
inputConfirm.textContent = ('input');
inputConfirm.classList = ('inputConfirm');
inputEmail.placeholder = 'Email';
Expand Down
45 changes: 20 additions & 25 deletions src/components/ejemplo.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
const div = document.createElement('div');
const title = document.createElement('h2');
const descriptionRegister = document.createElement('h3');
const button = document.createElement('button');
const buttonBack = document.createElement('button');
const buttonG = document.createElement('button');
const inputEmail = document.createElement('input');
const inputPass = document.createElement('input');
const inputConfirm = document.createElement('input');
button.textContent = 'Registrar';
button.classList = ('button');
buttonBack.textContent = 'Menu de inicio';
buttonBack.classList = ('buttonBack');
buttonG.textContent = 'google';
buttonG.classList = ('buttonGoogle');
button.classList = ('button');
AUTH
// entrar con email y password
/* export const signWithEmailPassword = (email, password) => {
signInWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Signed in
const user = userCredential.user;
console.log(user);
// ...
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
console.log(error);
});
};

inputEmail.textContent = ('input');
inputEmail.classList = ('inputEmail');
inputPass.textContent = ('input');
inputPass.classList = ('inputPass');
inputConfirm.textContent = ('input');
inputConfirm.classList = ('inputConfirm');
// login cuando ya esten registrados
//
*/

inputEmail.placeholder = 'Email';
inputPass.placeholder = 'Contraseña';
inputConfirm.placeholder = 'Confirmar contraseña';
//funcion log out
14 changes: 14 additions & 0 deletions src/components/wall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const Wall = () => {
const div = document.createElement('div');
const title = document.createElement('h2');

div.classList.add('container-register');

title.textContent = 'Wall';
title.classList = ('postalkr');

// eslint-disable-next-line max-len
div.append(title);

return div;
};
54 changes: 36 additions & 18 deletions src/firebase/auth.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,55 @@
/* eslint-disable max-len */
import { getAuth, createUserWithEmailAndPassword, signInWithPopup, GoogleAuthProvider } from 'https://www.gstatic.com/firebasejs/9.9.4/firebase-auth.js';
import {
getAuth, onAuthStateChanged, signInWithEmailAndPassword, createUserWithEmailAndPassword, signInWithPopup, GoogleAuthProvider,
} from 'https://www.gstatic.com/firebasejs/9.9.4/firebase-auth.js';
import { app } from './config.js';

const auth = getAuth();

export const guardarUssuario = (email, password) => createUserWithEmailAndPassword(auth, email, password);


export const providerGoogle = new GoogleAuthProvider();


export const loginGoogle = ()=> {

export const loginGoogle = () => {
signInWithPopup(auth, providerGoogle)

.then((result) => {
.then((result) => {
// This gives you a Google Access Token. You can use it to access the Google API.
const credential = GoogleAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
// The signed-in user info.
const user = result.user;
console.log(user.email);
const credential = GoogleAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
// The signed-in user info.
const user = result.user;
console.log(user.email);
// ...
}).catch((error) => {
}).catch((error) => {
// Handle Errors here.
const errorCode = error.code;
const errorMessage = error.message;

// The email of the user's account used.
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
});
};

export const userObserver = (callBack) => {
const authObserver = getAuth();
onAuthStateChanged(authObserver, callBack);
};

export const signWithEmailPassword = (email, password) => {

signInWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Signed in
const user = userCredential.user;
// ...
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;

// The email of the user's account used.
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
});
}

15 changes: 15 additions & 0 deletions src/firebase/login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { getAuth, signInWithEmailAndPassword } from 'https://www.gstatic.com/firebasejs/9.9.4/firebase-auth.js';

const auth = getAuth();
signInWithEmailAndPassword(auth, email, password)
.then((userCredential) => {
// Signed in
const user = userCredential.user;
// ...
})
.catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
});

//video 24:30
Binary file modified src/imagen/fondo app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 21 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { Welcome } from './components/Welcome.js';
import { Login } from './components/Login.js';
import { Register } from './components/Register.js';
import { Wall } from './components/wall.js';
import {userObserver} from './firebase/auth.js';

const root = document.getElementById('root');
const routes = {
'/': Welcome,
'/': Welcome, //solo / para welcome
'/login': Login,
'/register': Register,
'/wall': Wall,
};

export const onNavigate = (pathname) => {
Expand All @@ -15,15 +18,29 @@ export const onNavigate = (pathname) => {
pathname,
window.location.origin + pathname,
);
root.removeChild(root.firstChild)
root.removeChild(root.firstChild);
root.appendChild(routes[pathname]());
};

const component = routes[window.location.pathname];

window.onpopstate = () => {
root.removeChild(root.firstChild)
root.removeChild(root.firstChild);
root.append(component());
};

root.appendChild(component());
root.appendChild(component());

userObserver ((user)=> {
console.log (user)
if (user) {

onNavigate ('/wall')
} else {
onNavigate ('/')
}

});


//hacer parte de login