-
Notifications
You must be signed in to change notification settings - Fork 39
Social Network equipo 14 #33
base: master
Are you sure you want to change the base?
Changes from all commits
de229ff
627ac60
7ec833b
12e91bd
25a9612
faa827e
6f74b07
75cc426
ff8c923
6bbcc69
6cd37ec
5e2d17a
0c6ffd5
77ac6ff
13f301f
730d57e
53711bb
ff63dd9
8d20375
26aa2cc
778689f
dcb5130
6fa57d4
a41f824
0073f65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,72 @@ | ||||||||||||
| import { postPage } from '../views/postpageProfile.js'; | ||||||||||||
|
|
||||||||||||
| export const db = firebase.firestore(); | ||||||||||||
| // Authentication | ||||||||||||
| const usersRef = db.collection('users'); | ||||||||||||
| const auth = firebase.auth(); | ||||||||||||
|
|
||||||||||||
| export function saveUser(user) { | ||||||||||||
| const { displayName, uid, photoURL, email } = user; | ||||||||||||
| const u = { | ||||||||||||
| displayName, | ||||||||||||
| uid, | ||||||||||||
| photoURL, | ||||||||||||
| email, | ||||||||||||
| }; | ||||||||||||
| usersRef.doc(user.uid).set(u); | ||||||||||||
| } | ||||||||||||
| export const login = (email, password) => { | ||||||||||||
|
Comment on lines
+17
to
+18
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Sugerencia |
||||||||||||
| auth.signInWithEmailAndPassword(email, password) | ||||||||||||
| .then((snap => { | ||||||||||||
| console.log(snap); | ||||||||||||
| postPage(); | ||||||||||||
| return snap.user; | ||||||||||||
| })) | ||||||||||||
| .catch((error => { | ||||||||||||
| let errorCode = error.code; | ||||||||||||
| let errorMessage = error.message; | ||||||||||||
| console.log(`Lo sentimos : ${errorCode} ${errorMessage} `); | ||||||||||||
| return error; | ||||||||||||
| })); | ||||||||||||
| }; | ||||||||||||
| export const signup = (email, password) => { | ||||||||||||
| auth.createUserWithEmailAndPassword(email, password) | ||||||||||||
| .then((snap => { | ||||||||||||
| console.log(snap); | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. En una versión de construcción esta bien tener los console.log( ) pero en una versión de producción (y más para revisión) se deben de quitar.
Suggested change
|
||||||||||||
| saveUser(snap.user); | ||||||||||||
| let mail = snap.user.email; | ||||||||||||
| alert(`${mail} registro exitoso!`); | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No se recomienda el uso de alerts porque suele ser confuso para el usuario. |
||||||||||||
| postPage(); | ||||||||||||
| return snap.user; | ||||||||||||
| })) | ||||||||||||
| .catch((error => { | ||||||||||||
| let errorCode = error.code; | ||||||||||||
| let errorMessage = error.message; | ||||||||||||
| alert(`lo sentimos: ${errorCode} ${errorMessage}`) | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. otro alert
Suggested change
|
||||||||||||
| return error; | ||||||||||||
| })); | ||||||||||||
| }; | ||||||||||||
| // Login with google | ||||||||||||
| export function loginGoogle() { | ||||||||||||
| let provider = new firebase.auth.GoogleAuthProvider(); | ||||||||||||
| return firebase.auth().signInWithPopup(provider) | ||||||||||||
| .then(snap => { | ||||||||||||
| saveUser(snap.user); | ||||||||||||
| postPage(); | ||||||||||||
| return snap.user; | ||||||||||||
| }); | ||||||||||||
| } | ||||||||||||
| // Login with Facebook | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Me agrada la forma breve que documentan su código con estos pequeños comentarios, eso esta genial.
Suggested change
|
||||||||||||
| export function loginFace() { | ||||||||||||
| var provider = new firebase.auth.FacebookAuthProvider(); | ||||||||||||
| return firebase.auth().signInWithPopup(provider) | ||||||||||||
| .then((result => { | ||||||||||||
| saveUser(result.user); | ||||||||||||
| postPage(); | ||||||||||||
| console.log(result.user); | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| return result.user; | ||||||||||||
| })); | ||||||||||||
| } | ||||||||||||
| // Add Post | ||||||||||||
|
|
||||||||||||
| export const postsRef = db.collection('posts'); | ||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,9 +4,35 @@ | |||||||||||
| <meta charset="UTF-8"> | ||||||||||||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||||||||||||
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||||||||||||
| <title>Document</title> | ||||||||||||
| <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.8.2/css/bulma.min.css"> | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bootstrap esta instalado abajo |
||||||||||||
| <link rel="stylesheet" href="style.css"> | ||||||||||||
| <title>social-network-recipes</title> | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regularmente una sola palabra puede describir mejor el titulo
Suggested change
|
||||||||||||
| </head> | ||||||||||||
| <body> | ||||||||||||
| <!-- TODO: Add SDKs for Firebase products that you want to use | ||||||||||||
| https://firebase.google.com/docs/web/setup#available-libraries --> | ||||||||||||
| <script src="https://www.gstatic.com/firebasejs/7.14.2/firebase.js"></script> | ||||||||||||
| <script> | ||||||||||||
| var firebaseConfig = { | ||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no se recomienda el uso de var
Suggested change
|
||||||||||||
| apiKey: "AIzaSyBucI_PfC9w2g4RpcojM47YE9aEcJrdUrA", | ||||||||||||
| authDomain: "social-network-recipes.firebaseapp.com", | ||||||||||||
| databaseURL: "https://social-network-recipes.firebaseio.com", | ||||||||||||
| projectId: "social-network-recipes", | ||||||||||||
| storageBucket: "social-network-recipes.appspot.com", | ||||||||||||
| messagingSenderId: "265483566973", | ||||||||||||
| appId: "1:265483566973:web:4eacc08547367e47ed1614", | ||||||||||||
| measurementId: "G-XTZT14HD22" | ||||||||||||
| }; | ||||||||||||
| firebase.initializeApp(firebaseConfig); | ||||||||||||
| firebase.analytics(); | ||||||||||||
| </script> | ||||||||||||
| <script type="module" src="index.js"></script> | ||||||||||||
| <script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script> | ||||||||||||
| <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> | ||||||||||||
| <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script> | ||||||||||||
| <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> | ||||||||||||
| <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> | ||||||||||||
|
Comment on lines
+31
to
+34
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dos Frameworks de estilos causara conflictos, no es nada recomendable, decidan desde un inicio que utilizar ¿bulma o bootstrap? en caso de que cambien por uno o por otro se recomienda que desinstalen el otro(borrando todas las dependencias)
Suggested change
|
||||||||||||
| <div id="root" class="root"></div> | ||||||||||||
| <div id = "footer"></div> | ||||||||||||
| </body> | ||||||||||||
| </html> | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me agrada que tengan la buena practica de nombran const a las variables que no cambian ;)