Compare commits

...

94 Commits

Author SHA1 Message Date
shobhitm23
d3bfd8b5f3 Fixing UI 2019-11-01 15:36:22 -04:00
DreamCoder23
16567e2373 Merge pull request #63 from ClaytonWWilson/auth-backend-3
Auth backend 3
2019-10-29 14:40:02 -04:00
Aaron Sun
d3a77afe43 Pulled and merged the latest code from master 2019-10-29 14:02:56 -04:00
Aaron Sun
42b73632c0 Delete user's posts fully works now 2019-10-29 10:34:09 -04:00
Aaron Sun
c482f56762 Invalid credential message displays after non-exisitng email is passed in 2019-10-28 20:14:38 -04:00
Aaron Sun
9525ff7d0a Delete post works in Postman but not in actual database 2019-10-28 17:57:03 -04:00
Shobhit Makhija
f602b8251f Merge pull request #61 from ClaytonWWilson/filteredPosts
Arrow-callback warning
2019-10-28 01:34:43 -04:00
shobhitm23
70a12dcca4 Arrow-callback warning 2019-10-28 00:21:29 -04:00
Aaron Sun
657277bcad Username and user id now show in post data 2019-10-27 23:11:24 -04:00
Aaron Sun
d69828ef7f Merge branch 'master' of https://github.com/ClaytonWWilson/CS307-Team24 into auth-backend-3 2019-10-27 20:48:15 -04:00
Aaron Sun
5fa4caf0a3 Log in with username fully works now 2019-10-27 17:47:04 -04:00
Aaron Sun
fd226b454e Delete users fully works now 2019-10-27 14:46:31 -04:00
Leon Liang
0bbc453d54 Merge pull request #55 from ClaytonWWilson/delete_topic
Delete topic
2019-10-27 00:10:56 -04:00
Leon Liang
e236ceeb4b Merge branch 'master' into delete_topic 2019-10-27 00:10:38 -04:00
Leon Liang
1c81ae1663 show user's profile image 2019-10-27 00:09:17 -04:00
Leon Liang
c356dd18fa added UI allowing topic creation 2019-10-27 00:08:38 -04:00
Aditya Sankaran
19780a1395 made userline not hardcoded 2019-10-26 17:06:42 -04:00
Aditya Sankaran
981795b288 writing microblogs not hardcoded anymore 2019-10-26 16:57:25 -04:00
Leon Liang
ec041732d9 reformat 2019-10-25 23:14:25 -04:00
Leon Liang
eb3766edb2 Merge pull request #54 from ClaytonWWilson/delete_topic
added function to delete topic
2019-10-25 23:13:27 -04:00
Leon Liang
d9f6fb5d8e added function to delete topic 2019-10-25 23:04:09 -04:00
b31a571b29 Add followedTopics array on signup 2019-10-25 19:27:45 -04:00
60f83da514 Merge pull request #47 from ClaytonWWilson/block_topics
Fix login page loop bug
2019-10-25 15:31:12 -04:00
41bcc78c3a Fix login page loop bug 2019-10-25 15:20:10 -04:00
f82f9984c6 Comment out axios.defaults.baseUrl 2019-10-25 14:33:23 -04:00
Aditya Sankaran
6335690046 Merge branch 'master' of https://github.com/ClaytonWWilson/CS307-Team24 2019-10-25 13:15:53 -04:00
Aditya Sankaran
9d1f987ac1 added userID property for posts 2019-10-25 13:15:17 -04:00
Leon Liang
b255006f7a Merge pull request #45 from ClaytonWWilson/display_topic
Display topic
2019-10-25 01:57:14 -04:00
Leon Liang
f13580c727 display topics under profile 2019-10-25 01:56:07 -04:00
Leon Liang
4ec560de75 made logo background transparent 2019-10-25 00:00:43 -04:00
Leon Liang
65ac1c7384 Merge pull request #43 from ClaytonWWilson/add_topic_user
created functions retrieving all topics
2019-10-24 23:13:39 -04:00
Leon Liang
340d3537a6 created functions retrieving all topics 2019-10-24 23:13:03 -04:00
Leon Liang
de44f1eb89 Merge branch 'master' of github.com:ClaytonWWilson/CS307-Team24 2019-10-24 22:43:32 -04:00
Leon Liang
5405d96150 created function to add topic 2019-10-24 22:42:46 -04:00
0e6af081fa Merge pull request #42 from ClaytonWWilson/update-navbar
Update navbar
2019-10-24 22:41:04 -04:00
Clayton Wilson
021e25de86 Make NavBar display login/signup/logout correctly 2019-10-24 22:38:42 -04:00
Leon Liang
de38339cad Merge pull request #39 from ClaytonWWilson/profile_display
Profile display: able to see from /user
2019-10-24 22:12:27 -04:00
Leon Liang
a498b4748f Merge branch 'master' into profile_display 2019-10-24 22:12:02 -04:00
Leon Liang
4200c05ca1 added profile display 2019-10-24 22:08:49 -04:00
Leon Liang
6e9a86e5ce changed getUser 2019-10-24 22:08:28 -04:00
Leon Liang
97650f6539 added axios baseURL 2019-10-24 22:08:09 -04:00
Leon Liang
4aa029c649 modified getUserDetails 2019-10-24 19:34:31 -04:00
1b3ac4d05a Merge pull request #35 from ClaytonWWilson/edit-profile-fix
Fixing editProfile bugs and making the database storage more efficient
2019-10-24 19:32:05 -04:00
64c10cd172 Rename variable to make code more concise 2019-10-24 19:30:21 -04:00
Leon Liang
37cce6c828 deleted profile.js 2019-10-24 17:48:39 -04:00
Leon Liang
bcaf0920a6 deleted staticProfile 2019-10-24 17:45:41 -04:00
Leon Liang
b16c3eb50f Merge pull request #33 from ClaytonWWilson/auth-backend-3
Auth backend 3
2019-10-24 17:09:58 -04:00
Leon Liang
79d23af3fc Merge branch 'master' into auth-backend-3 2019-10-24 17:09:45 -04:00
Leon Liang
52bd8eed64 Merge branch 'master' of github.com:ClaytonWWilson/CS307-Team24 2019-10-24 17:07:29 -04:00
Leon Liang
ac28b3e19e getUserDetails is now working 2019-10-24 17:06:44 -04:00
Leon Liang
570866ff40 getUserDetail returns only user handle 2019-10-24 16:27:22 -04:00
Leon Liang
bdad36957c package lock 2019-10-24 16:25:29 -04:00
Leon Liang
e524bc2811 pass in fbAuth to getUserDetails 2019-10-24 16:25:19 -04:00
Leon Liang
714e6a4e07 new adminsdk 2019-10-24 16:24:56 -04:00
Leon Liang
cdbf0fcdc6 renew adminsdk 2019-10-24 16:24:33 -04:00
Clayton Wilson
8f5020f881 Fixing editProfile bugs and making the database storage more efficient 2019-10-24 15:44:53 -04:00
Aaron Sun
eea2f56b49 Code for removing user from db still in progress (commented out) 2019-10-24 15:27:20 -04:00
de4018a6d2 Merge pull request #34 from ClaytonWWilson/edit-profile-fix
Update fbAuth so the user data from firebase is stored in req.userData
2019-10-24 13:23:03 -04:00
Clayton Wilson
b17fb1f3f0 Update fbAuth so the user data from firebase is stored in req.userData 2019-10-23 23:16:43 -04:00
Aaron Sun
45f88861c8 Delete Account works on the UI now 2019-10-23 18:08:42 -04:00
Aaron Sun
ad853923c8 Delete Account on UI can log the user out 2019-10-23 17:18:52 -04:00
Aaron Sun
bc0b2549b4 Delete user backend code works 2019-10-22 20:45:48 -04:00
Leon Liang
e984afff74 modified profile.js 2019-10-22 18:26:21 -04:00
Aaron Sun
1b66f18dd5 Log in with username partially works 2019-10-22 16:50:38 -04:00
Leon Liang
dede04aa8e added dependency 2019-10-22 15:08:38 -04:00
Leon Liang
bb0343ab30 Remove redundant profile 2019-10-22 15:08:07 -04:00
Aaron Sun
7b8e40c7b0 Merge branch 'master' of https://github.com/ClaytonWWilson/CS307-Team24 2019-10-22 14:33:46 -04:00
c5942a6634 Merge pull request #31 from ClaytonWWilson/login-frontend
Comment out extra /user path declaration
2019-10-22 13:57:05 -04:00
e062ffbb41 Comment out extra /user path declaration 2019-10-22 13:17:43 -04:00
Aaron Sun
cb4885cadf Switched proxy back to cloud 2019-10-20 21:49:21 -04:00
Aaron Sun
d2032eef75 Login with username works now 2019-10-20 21:45:24 -04:00
adf3da4bb8 Merge pull request #29 from ClaytonWWilson/login-frontend
Login frontend
2019-10-11 18:24:13 -04:00
76ef3a6561 Fixing merge conflicts 2019-10-11 17:58:55 -04:00
b337277aa4 Fix login-frontend merge conflicts 2019-10-11 17:46:38 -04:00
f4b44c9654 Fix for Redux DevTools not being installed causing a crash 2019-10-11 17:35:21 -04:00
27efa858d5 Signup is working 2019-10-11 17:34:35 -04:00
00ed9d64c5 store.js 2019-10-10 14:13:04 -04:00
d1233e77ed Logout is working now : ) 2019-10-09 12:03:57 -04:00
bb6c7a07fc Register.js renamed to Signup.js 2019-10-07 21:00:52 -04:00
9eb4f603df Logout is working ^_^ 2019-10-07 20:46:28 -04:00
8179b51844 Before finishing authentication 2019-10-07 20:24:23 -04:00
Danny Voltz
f1e5c584e1 added alert 2019-10-03 12:00:58 -05:00
Leon Liang
c2ef222cf6 Merge pull request #28 from ClaytonWWilson/profile_display
Profile display
2019-10-03 11:53:31 -04:00
Leon Liang
3cbcb5054c Modifed user.js using grid displaying 2019-10-03 11:46:50 -04:00
6deb15d9d4 Merge pull request #27 from ClaytonWWilson/login-frontend
Login frontend
2019-10-03 11:42:10 -04:00
4a5c404be3 Merge branch 'master' into login-frontend 2019-10-03 11:39:38 -04:00
7841fa1798 Fix warning 2019-10-03 11:23:28 -04:00
Leon Liang
bac2cd7719 modified app.css to adjust the app background 2019-10-03 11:06:14 -04:00
f14e8bd970 Redux saves user data on login 2019-10-03 10:58:45 -04:00
c241455c4b Merge branch 'master' of https://github.com/ClaytonWWilson/CS307-Team24 2019-10-03 10:20:12 -04:00
4c1459d890 Renamed edit.js to editProfile.js because it makes more sense 2019-10-03 09:47:07 -04:00
8de496826a Testing login backend 2019-10-02 22:53:31 -04:00
5df28e0e77 Still working on Auth State 2019-10-02 17:53:20 -04:00
dcd03d7888 Login frontend complete 2019-10-02 00:49:51 -04:00
42 changed files with 1619 additions and 512 deletions

View File

@@ -1,17 +1,18 @@
/* eslint-disable prefer-arrow-callback */
/* eslint-disable promise/always-return */ /* eslint-disable promise/always-return */
const admin = require('firebase-admin'); const admin = require('firebase-admin');
exports.putPost = (req, res) => {
exports.putPost = (req, res) => {
const newPost = { const newPost = {
body: req.body.body, body: req.body.body,
userHandle: req.body.userHandle, userHandle: req.user.handle,
userImage: req.body.userImage, userImage: req.body.userImage,
userID: req.user.uid,
microBlogTitle: req.body.microBlogTitle, microBlogTitle: req.body.microBlogTitle,
createdAt: new Date().toISOString(), createdAt: new Date().toISOString(),
likeCount: 0, likeCount: 0,
commentCount: 0, commentCount: 0,
microBlogTopics: req.body.microBlogTopics microBlogTopics: req.body.microBlogTopics
}; };
admin.firestore().collection('posts').add(newPost) admin.firestore().collection('posts').add(newPost)
@@ -27,8 +28,7 @@ exports.putPost = (req, res) => {
}; };
exports.getallPostsforUser = (req, res) => { exports.getallPostsforUser = (req, res) => {
admin.firestore().collection('posts').where('userHandle', '==', req.userData.handle ).get()
admin.firestore().collection('posts').where('userHandle', '==', 'new user' ).get()
.then((data) => { .then((data) => {
let posts = []; let posts = [];
data.forEach(function(doc) { data.forEach(function(doc) {
@@ -40,4 +40,8 @@ exports.getallPostsforUser = (req, res) => {
console.error(err); console.error(err);
return res.status(500).json({error: 'Failed to fetch all posts written by specific user.'}) return res.status(500).json({error: 'Failed to fetch all posts written by specific user.'})
}) })
} };
exports.getFilteredPosts = (req, res) => {
admin.firestore().collection('posts').where('userHandle', '==', 'new user').where('microBlogTopics', '==')
};

View File

@@ -0,0 +1,52 @@
/* eslint-disable promise/always-return */
const { admin, db } = require("../util/admin");
exports.putTopic = (req, res) => {
const newTopic = {
topic: req.body.topic
};
admin.firestore().collection('topics').add(newTopic)
.then((doc) => {
const resTopic = newTopic;
newTopic.topicId = doc.id;
return res.status(200).json(resTopic);
})
.catch((err) => {
console.error(err);
return res.status(500).json({ error: 'something is wrong'});
});
};
exports.getAllTopics = (req, res) => {
admin.firestore().collection('topics').get()
.then((data) => {
let topics = [];
data.forEach(function(doc) {
topics.push(doc.data());
});
return res.status(200).json(topics);
})
.catch((err) => {
console.error(err);
return res.status(500).json({error: 'Failed to fetch all topics.'})
})
};
exports.deleteTopic = (req, res) => {
const topic = db.doc(`/topics/${req.params.topicId}`);
topic.get().then((doc) => {
if (!doc.exists) {
return res.status(404).json({error: 'Topic not found'});
} else {
return topic.delete();
}
})
.then(() => {
res.json({ message: 'Topic successfully deleted!'});
})
.catch((err) => {
console.error(err);
return res.status(500).json({error: 'Failed to delete topic.'})
})
}

View File

@@ -1,4 +1,5 @@
/* eslint-disable promise/catch-or-return */ /* eslint-disable promise/catch-or-return */
const { admin, db } = require("../util/admin"); const { admin, db } = require("../util/admin");
const config = require("../util/config"); const config = require("../util/config");
const { validateUpdateProfileInfo } = require("../util/validator"); const { validateUpdateProfileInfo } = require("../util/validator");
@@ -50,7 +51,7 @@ exports.signup = (req, res) => {
return res.status(400).json(errors); return res.status(400).json(errors);
} }
let idToken, userId; let token, userId;
db.doc(`/users/${newUser.handle}`) db.doc(`/users/${newUser.handle}`)
.get() .get()
@@ -68,18 +69,19 @@ exports.signup = (req, res) => {
userId = data.user.uid; userId = data.user.uid;
return data.user.getIdToken(); return data.user.getIdToken();
}) })
.then((token) => { .then((idToken) => {
idToken = token; token = idToken;
const userCred = { const userCred = {
email: req.body.email, email: newUser.email,
handle: newUser.handle, handle: newUser.handle,
createdAt: newUser.createdAt, createdAt: newUser.createdAt,
userId userId,
followedTopics: []
}; };
return db.doc(`/users/${newUser.handle}`).set(userCred); return db.doc(`/users/${newUser.handle}`).set(userCred);
}) })
.then(() => { .then(() => {
return res.status(201).json({ idToken }); return res.status(201).json({ token });
}) })
.catch((err) => { .catch((err) => {
console.error(err); console.error(err);
@@ -99,21 +101,37 @@ exports.login = (req, res) => {
// Auth validation // Auth validation
let errors = {}; let errors = {};
// Email check const emailRegEx = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
// Checks if email/username field is empty
if (user.email.trim() === "") { if (user.email.trim() === "") {
errors.email = "Email must not be blank."; errors.email = "Email must not be blank.";
} }
// Password check // Checks if password field is empty
if (user.password.trim() === "") { if (user.password.trim() === "") {
errors.password = "Password must not be blank."; errors.password = "Password must not be blank.";
} }
// Checking if any errors have been raised // Checks if any of the above two errors were found
if (Object.keys(errors).length > 0) { if (Object.keys(errors).length > 0) {
return res.status(400).json(errors); return res.status(400).json(errors);
} }
// Email/username field is username since it's not in email format
if (!user.email.match(emailRegEx)) {
var userDoc = db.collection("users").doc(`${user.email}`);
userDoc.get()
.then(function(doc) {
if (doc.exists) {
user.email = doc.data().email;
}
else {
return res.status(403).json({ general: "Invalid credentials. Please try again." });
}
return;
})
.then(function() {
firebase firebase
.auth() .auth()
.signInWithEmailAndPassword(user.email, user.password) .signInWithEmailAndPassword(user.email, user.password)
@@ -121,17 +139,98 @@ exports.login = (req, res) => {
return data.user.getIdToken(); return data.user.getIdToken();
}) })
.then((token) => { .then((token) => {
return res.json({ token }); return res.status(200).json({ token });
}) })
.catch((err) => { .catch((err) => {
console.error(err); console.error(err);
if (err.code === "auth/wrong-password") { if (err.code === "auth/user-not-found" || err.code === "auth/invalid-email" || err.code === "auth/wrong-password") {
return res.status(403).json({ general: "Invalid credentials. Please try again." });
}
return res.status(500).json({ error: err.code });
});
return;
})
.catch(function(err) {
if(!doc.exists) {
return res.status(403).json({ general: "Invalid credentials. Please try again." });
}
return res.status(500).send(err);
});
}
// Email/username field is username
else {
firebase
.auth()
.signInWithEmailAndPassword(user.email, user.password)
.then((data) => {
return data.user.getIdToken();
})
.then((token) => {
return res.status(200).json({ token });
})
.catch((err) => {
console.error(err);
if (err.code === "auth/user-not-found" || err.code === "auth/invalid-email" || err.code === "auth/wrong-password") {
return res return res
.status(403) .status(403)
.json({ general: "Invalid credentials. Please try again." }); .json({ general: "Invalid credentials. Please try again." });
} }
return res.status(500).json({ error: err.code }); return res.status(500).json({ error: err.code });
}); });
}
};
//Deletes user account
exports.deleteUser = (req, res) => {
var currentUser;
firebase.auth().onAuthStateChanged(function(user) {
currentUser = user;
if (currentUser) {
var post_query = db.collection("posts").where("userHandle", "==", req.user.handle);
post_query.get()
.then(function(myPosts) {
myPosts.forEach(function(doc) {
doc.ref.delete();
});
return;
})
.then(function() {
res.status(200).send("Successfully removed all user's posts from database.");
return;
})
.catch(function(err) {
res.status(500).send("Failed to remove all user's posts from database.", err);
});
db.collection("users").doc(`${req.user.handle}`).delete()
.then(function() {
res.status(200).send("Sucessfully removed user from database.");
return;
})
.catch(function(err) {
res.status(500).send("Failed to remove user from database.", err);
});
currentUser.delete()
.then(function() {
console.log("Successfully deleted user.");
res.status(200).send("Sucessfully deleted user.");
return;
})
.catch(function(err) {
console.log("Failed to delete user.", err);
res.status(500).send("Failed to delete user.");
});
}
else {
console.log("Failed to deleter user or cannot get user.");
res.status(500).send("Failed to deleter user or cannot get user.");
}
});
}; };
// Returns all data in the database for the user who is currently signed in // Returns all data in the database for the user who is currently signed in
@@ -150,10 +249,8 @@ exports.getProfileInfo = (req, res) => {
// Updates the data in the database of the user who is currently logged in // Updates the data in the database of the user who is currently logged in
exports.updateProfileInfo = (req, res) => { exports.updateProfileInfo = (req, res) => {
// TODO: Add functionality for adding/updating profile images
// Data validation // Data validation
const { valid, errors, profileData } = validateUpdateProfileInfo(req.body); const { valid, errors, profileData } = validateUpdateProfileInfo(req);
if (!valid) return res.status(400).json(errors); if (!valid) return res.status(400).json(errors);
// Update the database entry for this user // Update the database entry for this user
@@ -178,39 +275,36 @@ exports.updateProfileInfo = (req, res) => {
exports.getUserDetails = (req, res) => { exports.getUserDetails = (req, res) => {
let userData = {}; let userData = {};
db.doc(`/users/${req.params.handle}`) db.doc(`/users/${req.body.handle}`)
.get() .get()
.then((doc) => { .then((doc) => {
if (doc.exists) { if (doc.exists) {
userData.user = doc.data(); userData = doc.data();
return db return res.status(200).json({userData});
.collection("post")
.where("userHandle", "==", req.params.handle)
.orderBy("createdAt", "desc")
.get();
} else { } else {
return res.status(404).json({ return res.status(400).json({error: "User not found."})
error: "User not found" }})
});
}
})
.then((data) => {
userData.posts = [];
data.forEach((doc) => {
userData.posts.push({
body: doc.data().body,
createAt: doc.data().createAt,
userHandle: doc.data().userHandle,
userImage: doc.data().userImage,
likeCount: doc.data().likeCount,
commentCount: doc.data().commentCount,
postId: doc.id
});
});
return res.json(userData);
})
.catch((err) => { .catch((err) => {
console.error(err); console.error(err);
return res.status(500).json({ error: err.code }); return res.status(500).json({ error: err.code });
}); });
}; };
exports.getAuthenticatedUser = (req, res) => {
let credentials = {};
db.doc(`/users/${req.user.handle}`)
.get()
.then((doc) => {
if (doc.exists) {
credentials = doc.data();
return res.status(200).json({credentials});
} else {
return res.status(400).json({error: "User not found."})
}})
.catch((err) => {
console.error(err);
return res.status(500).json({ error: err.code });
});
};

View File

@@ -10,10 +10,12 @@ app.use(cors());
* handlers/users.js * * handlers/users.js *
*------------------------------------------------------------------*/ *------------------------------------------------------------------*/
const { const {
getAuthenticatedUser,
getUserDetails, getUserDetails,
getProfileInfo, getProfileInfo,
login, login,
signup, signup,
deleteUser,
updateProfileInfo updateProfileInfo
} = require("./handlers/users"); } = require("./handlers/users");
@@ -26,7 +28,10 @@ app.post("/signup", signup);
// and password // and password
app.post("/login", login); app.post("/login", login);
app.get("/getUser/:handle", getUserDetails); //Deletes user account
app.delete("/delete", fbAuth, deleteUser);
app.get("/getUser", fbAuth, getUserDetails);
// Returns all profile data of the currently logged in user // Returns all profile data of the currently logged in user
app.get("/getProfileInfo", fbAuth, getProfileInfo); app.get("/getProfileInfo", fbAuth, getProfileInfo);
@@ -34,14 +39,35 @@ app.get("/getProfileInfo", fbAuth, getProfileInfo);
// Updates the currently logged in user's profile information // Updates the currently logged in user's profile information
app.post("/updateProfileInfo", fbAuth, updateProfileInfo); app.post("/updateProfileInfo", fbAuth, updateProfileInfo);
app.get("/user", fbAuth, getAuthenticatedUser);
/*------------------------------------------------------------------* /*------------------------------------------------------------------*
* handlers/post.js * * handlers/post.js *
*------------------------------------------------------------------*/ *------------------------------------------------------------------*/
const { getallPostsforUser, putPost } = require("./handlers/post"); const { getallPostsforUser, putPost
} = require("./handlers/post");
app.get("/getallPostsforUser", getallPostsforUser); app.get("/getallPostsforUser", getallPostsforUser);
// Adds one post to the database // Adds one post to the database
app.post("/putPost", fbAuth, putPost); app.post("/putPost", fbAuth, putPost);
/*------------------------------------------------------------------*
* handlers/topic.js *
*------------------------------------------------------------------*/
const {
putTopic,
getAllTopics,
deleteTopic
} = require("./handlers/topic");
// add topic to database
app.post("/putTopic", fbAuth, putTopic);
// get all topics from database
app.get("/getAllTopics", fbAuth, getAllTopics);
// delete a specific topic
app.delete("/deleteTopic/:topicId", fbAuth, deleteTopic);
exports.api = functions.https.onRequest(app); exports.api = functions.https.onRequest(app);

View File

@@ -34,21 +34,6 @@
"dom-storage": "2.1.0", "dom-storage": "2.1.0",
"tslib": "1.10.0", "tslib": "1.10.0",
"xmlhttprequest": "1.8.0" "xmlhttprequest": "1.8.0"
},
"dependencies": {
"@firebase/logger": {
"version": "0.1.25",
"resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.1.25.tgz",
"integrity": "sha512-/lRhuepVcCCnQ2jcO5Hr08SYdmZDTQU9fdPdzg+qXJ9k/QnIrD2RbswXQcL6mmae3uPpX7fFXQAoScJ9pzp50w=="
},
"@firebase/util": {
"version": "0.2.28",
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
"integrity": "sha512-ZQMAWtXj8y5kvB6izs0aTM/jG+WO8HpqhXA/EwD6LckJ+1P5LnAhaLZt1zR4HpuCE+jeP5I32Id5RJ/aifFs6A==",
"requires": {
"tslib": "1.10.0"
}
}
} }
}, },
"@firebase/app-types": { "@firebase/app-types": {
@@ -70,15 +55,9 @@
"integrity": "sha512-foQHhvyB0RR+mb/+wmHXd/VOU+D8fruFEW1k79Q9wzyTPpovMBa1Mcns5fwEWBhUfi8bmoEtaGB8RSAHnTFzTg==" "integrity": "sha512-foQHhvyB0RR+mb/+wmHXd/VOU+D8fruFEW1k79Q9wzyTPpovMBa1Mcns5fwEWBhUfi8bmoEtaGB8RSAHnTFzTg=="
}, },
"@firebase/database": { "@firebase/database": {
<<<<<<< HEAD
"version": "0.5.3",
"resolved": "https://registry.npmjs.org/@firebase/database/-/database-0.5.3.tgz",
"integrity": "sha512-LnXKRE1AmjlS+iRF7j8vx+Ni8x85CmLP5u5Pw5rDKhKLn2eTR1tJKD937mUeeGEtDHwR1rrrkLYOqRR2cSG3hQ==",
=======
"version": "0.5.4", "version": "0.5.4",
"resolved": "https://registry.npmjs.org/@firebase/database/-/database-0.5.4.tgz", "resolved": "https://registry.npmjs.org/@firebase/database/-/database-0.5.4.tgz",
"integrity": "sha512-Hz1Bi3fzIcNNocE4EhvvwoEQGurG2BGssWD3/6a2bzty+K1e57SLea2Ied8QYNBUU1zt/4McHfa3Y71EQIyn/w==", "integrity": "sha512-Hz1Bi3fzIcNNocE4EhvvwoEQGurG2BGssWD3/6a2bzty+K1e57SLea2Ied8QYNBUU1zt/4McHfa3Y71EQIyn/w==",
>>>>>>> 7969d3b10bc35a9078834c5ee2ba8c8fd60d338f
"requires": { "requires": {
"@firebase/database-types": "0.4.3", "@firebase/database-types": "0.4.3",
"@firebase/logger": "0.1.25", "@firebase/logger": "0.1.25",
@@ -113,11 +92,7 @@
"@firebase/firestore": { "@firebase/firestore": {
"version": "1.5.3", "version": "1.5.3",
"resolved": "https://registry.npmjs.org/@firebase/firestore/-/firestore-1.5.3.tgz", "resolved": "https://registry.npmjs.org/@firebase/firestore/-/firestore-1.5.3.tgz",
<<<<<<< HEAD
"integrity": "sha512-CPYLvkGZBKE47oQC9a0q13UMVRj3LvnSbB1nOerktE3CGRHKy44LxDumamN8Kj067hV/80mKK9FdbeUufwO/Rg==",
=======
"integrity": "sha512-O/yAbXpitOA6g627cUl0/FHYlkTy1EiEKMKOlnlMOJF2fH+nLVZREXjsrCC7N2tIvTn7yYwfpZ4zpSNvrhwiTA==", "integrity": "sha512-O/yAbXpitOA6g627cUl0/FHYlkTy1EiEKMKOlnlMOJF2fH+nLVZREXjsrCC7N2tIvTn7yYwfpZ4zpSNvrhwiTA==",
>>>>>>> 7969d3b10bc35a9078834c5ee2ba8c8fd60d338f
"requires": { "requires": {
"@firebase/firestore-types": "1.5.0", "@firebase/firestore-types": "1.5.0",
"@firebase/logger": "0.1.25", "@firebase/logger": "0.1.25",
@@ -126,21 +101,6 @@
"@grpc/proto-loader": "^0.5.0", "@grpc/proto-loader": "^0.5.0",
"grpc": "1.23.3", "grpc": "1.23.3",
"tslib": "1.10.0" "tslib": "1.10.0"
},
"dependencies": {
"@firebase/logger": {
"version": "0.1.25",
"resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.1.25.tgz",
"integrity": "sha512-/lRhuepVcCCnQ2jcO5Hr08SYdmZDTQU9fdPdzg+qXJ9k/QnIrD2RbswXQcL6mmae3uPpX7fFXQAoScJ9pzp50w=="
},
"@firebase/util": {
"version": "0.2.28",
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
"integrity": "sha512-ZQMAWtXj8y5kvB6izs0aTM/jG+WO8HpqhXA/EwD6LckJ+1P5LnAhaLZt1zR4HpuCE+jeP5I32Id5RJ/aifFs6A==",
"requires": {
"tslib": "1.10.0"
}
}
} }
}, },
"@firebase/firestore-types": { "@firebase/firestore-types": {
@@ -173,16 +133,6 @@
"@firebase/util": "0.2.28", "@firebase/util": "0.2.28",
"idb": "3.0.2", "idb": "3.0.2",
"tslib": "1.10.0" "tslib": "1.10.0"
},
"dependencies": {
"@firebase/util": {
"version": "0.2.28",
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
"integrity": "sha512-ZQMAWtXj8y5kvB6izs0aTM/jG+WO8HpqhXA/EwD6LckJ+1P5LnAhaLZt1zR4HpuCE+jeP5I32Id5RJ/aifFs6A==",
"requires": {
"tslib": "1.10.0"
}
}
} }
}, },
"@firebase/installations-types": { "@firebase/installations-types": {
@@ -190,6 +140,11 @@
"resolved": "https://registry.npmjs.org/@firebase/installations-types/-/installations-types-0.1.2.tgz", "resolved": "https://registry.npmjs.org/@firebase/installations-types/-/installations-types-0.1.2.tgz",
"integrity": "sha512-fQaWIW8hyX1XUN7+FCSPjvM1agFjGidVuF4Sxi7aFwfyh5t+4fD2VpM4wCQbWmodnx4fZLvsuQd9mkxxU+lGYQ==" "integrity": "sha512-fQaWIW8hyX1XUN7+FCSPjvM1agFjGidVuF4Sxi7aFwfyh5t+4fD2VpM4wCQbWmodnx4fZLvsuQd9mkxxU+lGYQ=="
}, },
"@firebase/logger": {
"version": "0.1.25",
"resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.1.25.tgz",
"integrity": "sha512-/lRhuepVcCCnQ2jcO5Hr08SYdmZDTQU9fdPdzg+qXJ9k/QnIrD2RbswXQcL6mmae3uPpX7fFXQAoScJ9pzp50w=="
},
"@firebase/messaging": { "@firebase/messaging": {
"version": "0.4.11", "version": "0.4.11",
"resolved": "https://registry.npmjs.org/@firebase/messaging/-/messaging-0.4.11.tgz", "resolved": "https://registry.npmjs.org/@firebase/messaging/-/messaging-0.4.11.tgz",
@@ -198,16 +153,6 @@
"@firebase/messaging-types": "0.3.2", "@firebase/messaging-types": "0.3.2",
"@firebase/util": "0.2.28", "@firebase/util": "0.2.28",
"tslib": "1.10.0" "tslib": "1.10.0"
},
"dependencies": {
"@firebase/util": {
"version": "0.2.28",
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
"integrity": "sha512-ZQMAWtXj8y5kvB6izs0aTM/jG+WO8HpqhXA/EwD6LckJ+1P5LnAhaLZt1zR4HpuCE+jeP5I32Id5RJ/aifFs6A==",
"requires": {
"tslib": "1.10.0"
}
}
} }
}, },
"@firebase/messaging-types": { "@firebase/messaging-types": {
@@ -225,21 +170,6 @@
"@firebase/performance-types": "0.0.3", "@firebase/performance-types": "0.0.3",
"@firebase/util": "0.2.28", "@firebase/util": "0.2.28",
"tslib": "1.10.0" "tslib": "1.10.0"
},
"dependencies": {
"@firebase/logger": {
"version": "0.1.25",
"resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.1.25.tgz",
"integrity": "sha512-/lRhuepVcCCnQ2jcO5Hr08SYdmZDTQU9fdPdzg+qXJ9k/QnIrD2RbswXQcL6mmae3uPpX7fFXQAoScJ9pzp50w=="
},
"@firebase/util": {
"version": "0.2.28",
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
"integrity": "sha512-ZQMAWtXj8y5kvB6izs0aTM/jG+WO8HpqhXA/EwD6LckJ+1P5LnAhaLZt1zR4HpuCE+jeP5I32Id5RJ/aifFs6A==",
"requires": {
"tslib": "1.10.0"
}
}
} }
}, },
"@firebase/performance-types": { "@firebase/performance-types": {
@@ -272,8 +202,13 @@
"@firebase/storage-types": "0.3.3", "@firebase/storage-types": "0.3.3",
"@firebase/util": "0.2.28", "@firebase/util": "0.2.28",
"tslib": "1.10.0" "tslib": "1.10.0"
}
},
"@firebase/storage-types": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/@firebase/storage-types/-/storage-types-0.3.3.tgz",
"integrity": "sha512-fUp4kpbxwDiWs/aIBJqBvXgFHZvgoND2JA0gJYSEsXtWtVwfgzY/710plErgZDeQKopX5eOR1sHskZkQUy0U6w=="
}, },
"dependencies": {
"@firebase/util": { "@firebase/util": {
"version": "0.2.28", "version": "0.2.28",
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz", "resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
@@ -281,13 +216,6 @@
"requires": { "requires": {
"tslib": "1.10.0" "tslib": "1.10.0"
} }
}
}
},
"@firebase/storage-types": {
"version": "0.3.3",
"resolved": "https://registry.npmjs.org/@firebase/storage-types/-/storage-types-0.3.3.tgz",
"integrity": "sha512-fUp4kpbxwDiWs/aIBJqBvXgFHZvgoND2JA0gJYSEsXtWtVwfgzY/710plErgZDeQKopX5eOR1sHskZkQUy0U6w=="
}, },
"@firebase/webchannel-wrapper": { "@firebase/webchannel-wrapper": {
"version": "0.2.26", "version": "0.2.26",
@@ -608,10 +536,9 @@
"dev": true "dev": true
}, },
"ansi-regex": { "ansi-regex": {
"version": "3.0.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz",
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg=="
"dev": true
}, },
"ansi-styles": { "ansi-styles": {
"version": "3.2.1", "version": "3.2.1",
@@ -1190,15 +1117,9 @@
} }
}, },
"end-of-stream": { "end-of-stream": {
<<<<<<< HEAD
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz",
"integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==",
=======
"version": "1.4.3", "version": "1.4.3",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.3.tgz", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.3.tgz",
"integrity": "sha512-cbNhPFS6MlYlWTGncSiDYbdqKhwWFy7kNeb1YSOG6K65i/wPTkLVCJQj0hXA4j0m5Da+hBWnqopEnu1FFelisQ==", "integrity": "sha512-cbNhPFS6MlYlWTGncSiDYbdqKhwWFy7kNeb1YSOG6K65i/wPTkLVCJQj0hXA4j0m5Da+hBWnqopEnu1FFelisQ==",
>>>>>>> 7969d3b10bc35a9078834c5ee2ba8c8fd60d338f
"optional": true, "optional": true,
"requires": { "requires": {
"once": "^1.4.0" "once": "^1.4.0"
@@ -1280,6 +1201,12 @@
"text-table": "^0.2.0" "text-table": "^0.2.0"
}, },
"dependencies": { "dependencies": {
"ansi-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
"dev": true
},
"debug": { "debug": {
"version": "4.1.1", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
@@ -1294,6 +1221,15 @@
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
"dev": true "dev": true
},
"strip-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
"dev": true,
"requires": {
"ansi-regex": "^3.0.0"
}
} }
} }
}, },
@@ -1556,33 +1492,6 @@
"@firebase/polyfill": "0.3.22", "@firebase/polyfill": "0.3.22",
"@firebase/storage": "0.3.12", "@firebase/storage": "0.3.12",
"@firebase/util": "0.2.28" "@firebase/util": "0.2.28"
},
"dependencies": {
"@firebase/database": {
"version": "0.5.4",
"resolved": "https://registry.npmjs.org/@firebase/database/-/database-0.5.4.tgz",
"integrity": "sha512-Hz1Bi3fzIcNNocE4EhvvwoEQGurG2BGssWD3/6a2bzty+K1e57SLea2Ied8QYNBUU1zt/4McHfa3Y71EQIyn/w==",
"requires": {
"@firebase/database-types": "0.4.3",
"@firebase/logger": "0.1.25",
"@firebase/util": "0.2.28",
"faye-websocket": "0.11.3",
"tslib": "1.10.0"
}
},
"@firebase/logger": {
"version": "0.1.25",
"resolved": "https://registry.npmjs.org/@firebase/logger/-/logger-0.1.25.tgz",
"integrity": "sha512-/lRhuepVcCCnQ2jcO5Hr08SYdmZDTQU9fdPdzg+qXJ9k/QnIrD2RbswXQcL6mmae3uPpX7fFXQAoScJ9pzp50w=="
},
"@firebase/util": {
"version": "0.2.28",
"resolved": "https://registry.npmjs.org/@firebase/util/-/util-0.2.28.tgz",
"integrity": "sha512-ZQMAWtXj8y5kvB6izs0aTM/jG+WO8HpqhXA/EwD6LckJ+1P5LnAhaLZt1zR4HpuCE+jeP5I32Id5RJ/aifFs6A==",
"requires": {
"tslib": "1.10.0"
}
}
} }
}, },
"firebase-admin": { "firebase-admin": {
@@ -1710,8 +1619,7 @@
"functional-red-black-tree": { "functional-red-black-tree": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz",
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc="
"optional": true
}, },
"gaxios": { "gaxios": {
"version": "2.0.1", "version": "2.0.1",
@@ -2259,15 +2167,9 @@
} }
}, },
"gtoken": { "gtoken": {
<<<<<<< HEAD
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-4.0.0.tgz",
"integrity": "sha512-XaRCfHJxhj06LmnWNBzVTAr85NfAErq0W1oabkdqwbq3uL/QTB1kyvGog361Uu2FMG/8e3115sIy/97Rnd4GjQ==",
=======
"version": "4.1.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-4.1.0.tgz", "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-4.1.0.tgz",
"integrity": "sha512-wqyn2gf5buzEZN4QNmmiiW2i2JkEdZnL7Z/9p44RtZqgt4077m4khRgAYNuu8cBwHWCc6MsP6eDUn/KkF6jFIw==", "integrity": "sha512-wqyn2gf5buzEZN4QNmmiiW2i2JkEdZnL7Z/9p44RtZqgt4077m4khRgAYNuu8cBwHWCc6MsP6eDUn/KkF6jFIw==",
>>>>>>> 7969d3b10bc35a9078834c5ee2ba8c8fd60d338f
"optional": true, "optional": true,
"requires": { "requires": {
"gaxios": "^2.0.0", "gaxios": "^2.0.0",
@@ -2441,8 +2343,7 @@
"imurmurhash": { "imurmurhash": {
"version": "0.1.4", "version": "0.1.4",
"resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz",
"integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o="
"optional": true
}, },
"inflight": { "inflight": {
"version": "1.0.6", "version": "1.0.6",
@@ -2457,8 +2358,7 @@
"inherits": { "inherits": {
"version": "2.0.4", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
"optional": true
}, },
"inquirer": { "inquirer": {
"version": "6.5.2", "version": "6.5.2",
@@ -2528,10 +2428,8 @@
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
"requires": { "dev": true
"number-is-nan": "^1.0.0"
}
}, },
"is-obj": { "is-obj": {
"version": "2.0.0", "version": "2.0.0",
@@ -2929,7 +2827,6 @@
"version": "1.4.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@@ -3374,8 +3271,7 @@
"signal-exit": { "signal-exit": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0="
"optional": true
}, },
"slice-ansi": { "slice-ansi": {
"version": "2.1.0", "version": "2.1.0",
@@ -3428,11 +3324,28 @@
"string-width": { "string-width": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",
"dev": true,
"requires": { "requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^2.0.0", "is-fullwidth-code-point": "^2.0.0",
"strip-ansi": "^4.0.0" "strip-ansi": "^4.0.0"
},
"dependencies": {
"ansi-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
"integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
"dev": true
},
"strip-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
"dev": true,
"requires": {
"ansi-regex": "^3.0.0"
}
}
} }
}, },
"string_decoder": { "string_decoder": {
@@ -3442,12 +3355,11 @@
"optional": true "optional": true
}, },
"strip-ansi": { "strip-ansi": {
"version": "4.0.0", "version": "5.2.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz",
"integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==",
"dev": true,
"requires": { "requires": {
"ansi-regex": "^3.0.0" "ansi-regex": "^4.1.0"
} }
}, },
"strip-json-comments": { "strip-json-comments": {
@@ -3755,8 +3667,7 @@
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
"optional": true
}, },
"write": { "write": {
"version": "1.0.3", "version": "1.0.3",

View File

@@ -16,7 +16,8 @@
"axios": "^0.19.0", "axios": "^0.19.0",
"firebase": "^6.6.2", "firebase": "^6.6.2",
"firebase-admin": "^8.6.0", "firebase-admin": "^8.6.0",
"firebase-functions": "^3.1.0" "firebase-functions": "^3.1.0",
"strip-ansi": "^5.2.0"
}, },
"devDependencies": { "devDependencies": {
"eslint": "^5.12.0", "eslint": "^5.12.0",

View File

@@ -4,6 +4,13 @@ const { admin, db } = require('./admin');
// The function will only execute if the user is logged in, or rather, they have // The function will only execute if the user is logged in, or rather, they have
// a valid token // a valid token
module.exports = (req, res, next) => { module.exports = (req, res, next) => {
console.log(req);
console.log(req.body);
console.log(req.headers);
console.log(req.headers.authorization);
console.log(JSON.stringify(req.body));
console.log(JSON.stringify(req.header));
let idToken; let idToken;
// Checking that the token exists in the header of the request // Checking that the token exists in the header of the request
@@ -25,6 +32,7 @@ module.exports = (req, res, next) => {
.then((data) => { .then((data) => {
req.user.handle = data.docs[0].data().handle; // Save username req.user.handle = data.docs[0].data().handle; // Save username
req.user.imageUrl = data.docs[0].data().imageUrl; req.user.imageUrl = data.docs[0].data().imageUrl;
req.userData = data.docs[0].data(); // Stores all user data from the database
return next(); return next();
}) })
.catch((err) => { .catch((err) => {

View File

@@ -9,23 +9,39 @@ const isEmpty = (str) => {
else return false; else return false;
}; };
exports.validateUpdateProfileInfo = (data) => { exports.validateUpdateProfileInfo = (req) => {
const newData = req.body;
// const oldData = req.userData;
let errors = {}; let errors = {};
let profileData = {}; let profileData = req.userData;
// ?: Should users be able to change their handles and emails? // ?: Should users be able to change their handles and emails?
// Only adds the key to the database if the values are not empty // Deletes any unused keys so that they aren't stored in the database
if (!isEmpty(data.firstName)) profileData.firstName = data.firstName.trim(); if (newData.firstName) {
if (!isEmpty(data.lastName)) profileData.lastName = data.lastName.trim(); profileData.firstName = newData.firstName.toString().trim();
if (!isEmpty(data.bio)) profileData.bio = data.bio.trim(); } else {
delete profileData.firstName;
}
if (isEmpty(data.email)) { if (newData.lastName) {
profileData.lastName = newData.lastName.toString().trim();
} else {
delete profileData.lastName;
}
if (newData.bio) {
profileData.bio = newData.bio.toString().trim();
} else {
delete profileData.bio;
}
if (isEmpty(newData.email)) {
errors.email = "Must not be empty."; errors.email = "Must not be empty.";
} else if (!isEmail(data.email)) { } else if (!isEmail(newData.email)) {
errors.email = "Must be a valid email."; errors.email = "Must be a valid email.";
} else { } else {
profileData.email = data.email; profileData.email = newData.email;
} }
return { return {

37
package-lock.json generated
View File

@@ -16,6 +16,15 @@
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
"integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
}, },
"axios": {
"version": "0.19.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
"integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==",
"requires": {
"follow-redirects": "1.5.10",
"is-buffer": "^2.0.2"
}
},
"body-parser": { "body-parser": {
"version": "1.19.0", "version": "1.19.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
@@ -164,6 +173,24 @@
"unpipe": "~1.0.0" "unpipe": "~1.0.0"
} }
}, },
"follow-redirects": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
"requires": {
"debug": "=3.1.0"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
}
}
},
"forwarded": { "forwarded": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
@@ -204,6 +231,16 @@
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz",
"integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA=="
}, },
"is-buffer": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
"integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A=="
},
"jwt-decode": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-2.2.0.tgz",
"integrity": "sha1-fYa9VmefWM5qhHBKZX3TkruoGnk="
},
"media-typer": { "media-typer": {
"version": "0.3.0", "version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",

View File

@@ -1,12 +0,0 @@
{
"type": "service_account",
"project_id": "twistter-e4649",
"private_key_id": "1e57494429e4fd7d17f6fc28524e14b8e5227596",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCyRdMZwXrpf3HB\nsVrGZVoPt+S+ahkT4SCCEWV/Q4O4hVyW277Rs0p7k5ZkZfkhcVVBUqKGMgW/Esvz\npx0VIgpg3gg308kMRmC3MGzYbodjynVyDHatyAZhhUi9cg0N2K9+vSsW5eSmWROe\nfVvB8hvr6m5xGVdJFA7DV4/0vm2cfy+Q/FlFb6vFmQTZtPZzGFf5BKoNMe7pMxey\n4zspAIZgRmxWDbAqqzX0PYk/WbXFgH/wn2X25S+ArHhoay2Hms65/NbWCV6mpFUJ\nYqzrlCn/WcwXGAm7tjmu00yD+bARabImh8R7+PSBaHMQ+SGdri2snIXWsvB/xi9/\nSNFqzHynAgMBAAECggEAVty/zapg1bnTt0FPziBfIA6FpaPzoSSN3uJUFozSdwuA\nAD+E/A9EiO7yFew71egvVrtJVmK0OxQRDSDNglkKPoWg8na+XL1D7a5qMpC0ZlKl\nJBNfljBCr6yuMySJqMf+Rp4siyUr4kO/0/cXyOnLYglhk7j5tzFPOi4FhgZtSRU9\nYckk5wwcBObUFE0Rmqf0gPcI9WuFUkusIjz3rjuEju1/U6E/VV5gHmMuQy3f9LHB\nnsiLAobx9+TGgs12CvkjWYpW5raUCCn5z/EYNPZSt7rg9CSWqXW009HCfTqi6i7o\nNpZ7qpp5DVQdHNFJunSGvI+k44+i8OE7HEY4xXt+OQKBgQDZ/E1QwJQoHuzPkrGW\nAc0a+NQeG8NwaXwsezlvYXMTbL27SxKXC3dzPT1WgNUKpaKj3wLJPar4NgPPSPi3\nqgmcvMqgwm4B+HPbXc1oxBS7/jD3pWJVyPO9Re17Uc0RYV/DORQhWe1Yq7TyMHvl\nbD/KqIvOxswigVxK4JMIxp4s7wKBgQDRXJfb4BHdR7CGfuTVQ19gH5uLgrK9ezBk\nQOLK+u9yBpoKyYSnD3OH/i0wG5bm3rUegzvwHGKKhDfiLbajMIt04n2DuVUm57HQ\n+Jca29V8XMWfhTbu3kDl+OOFmLvPCwg8C9edNTJWUVYu3EbwsyzCQY5TDroWGQdF\n6cQIkAIbyQKBgQCUtWd1UHuCR16cWOHniQEIhnoGtEAHHx9EJShQkLV1qfhhnlxn\nSL5LkpqWubsc0VR74LbA3N4XCJpevdRXT5vRHoZJV3q+w2UeYQaxkxrmCQoU1/GW\nvklxdRQGzg5M7hXrU7Qk8HlXxYPiuSq8n7WBJqyB+uLmI0P4HO6RzRW5ZwKBgBkr\nf5pQkvU+dCuHP+2fvuyogCPCn8iF8ehroJh0mKrlvklDtu36vpH/7eDVwEubRL0Z\nW/BfCT3L7YgEpOtzn6B6xko60tDtlAQijtAM09qysJOgCV2oXLcJOBlMpm+azO+j\nINXmmlmkR680jlbLw7rK9NhpcdfMRIKUOxwobAh5AoGBAJMN6n7Hy8nJRJZ18iHY\n3hEkVbKrLLMMHFDQj5BZQCeAp1v0Fj30RYJWS4hTzR9ht0MtdmPub460lh9hhqCM\nl3UnCJoz00ApF3Z2FRN/l0KpCFD9Gw2Hjyc3u9sEUpqd8G3cg3IZE6eZ6CZWljFT\nHcuQ2cTFdB8bq8oLUxXeY3Yv\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-pgjve@twistter-e4649.iam.gserviceaccount.com",
"client_id": "102241295911303209723",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-pgjve%40twistter-e4649.iam.gserviceaccount.com"
}

View File

@@ -0,0 +1,12 @@
{
"type": "service_account",
"project_id": "twistter-e4649",
"private_key_id": "382fc005e17340a21dd39079feca75371330644d",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDL1bwTpEluR6dJ\nVfS/K1d76j2I3Wrn4qSbrTYm4/cAPBPlsBRO0bwrkhr+g0I6rwW/fFz8udjNAFB1\nfDfz769buR6go5us71I5LxMNviIhzFr59ZsEkcnUCgW8G7koicLEjWdstI4lJxZT\nRRolH+SFpPwsQAY399zjdBiCC8STbavVVhe+ChEDl/S2K72W7A7nWSMbLsyGsz2o\nQ9uIG3onwFNE7WRIeObWCxSBKlydMmTJ+p/CsTdFY4fUHb97QsMEmzRJox10kmyt\nP9l5wfJ2wUYvRXRJKq7Mwx1UnLduXP2oe/XvR5fzJLJ780HO6BNBf5IKcTHXHVBA\ne6ZtiL5dAgMBAAECggEAFvfN1NttjXL0KKak3hMA1+z8Y2WqXC1aUFMOMlz8Qhct\nmXNjy8CFAYEvGtVTgHqkR9Vi7PShYfLSc3U8diI155H5H4S6pUaPmfNHTwRzosyn\ncQRPJA6sEqvRGvHMxVfwjbvultMpiTTZpnxiMSNiLqT5PUs26CuSb5bErt1V7dP5\nn/lhY+4rzfXSrw38ZsO/gEvLZ/7iRA+JZgqE3Qs2cD5idxqqOcOLLiW741JpXTmd\n5ug/urJgSyvz+cNo3yHnajEtAxiSfkpU4sUHZ/WWqaRGWxpt3XWILtR9Q/4afPeM\n/T82YvddoW5pUwDpgvZxdVYjopuoxvnS298L0AGySQKBgQDqDD7Yh6SbOR3w4ZN9\nRO7q5KiJbyZmVdZ3lLZddsL/vto9JkUtnLDOMpYnb2TezGfN6ErzAkRQCSUsWK4m\nERbSK6oyUvevhlt/gHGP34uc/OCxGk2D7WCAS3s54ofDt2369tzIpGjsnkYM+h3b\nuZ5lFoWHG1YM3JtgcIIU6UygTwKBgQDe9ArV08wPDuXf4rcldmImQDB7xhGcg9xU\njAKEn5FZW1mvmBy3Sq1qpZj0baZz6eEDn6FBLwH1Ke5gdfrd8WnESUNnFnBBqpA1\nospIgUmKZ1sjyly9CHMQ11Kbzt7+kA9GYZrMbaMjS8M18qFEBZ7CoPLv5DLyabJW\nOkPzTwb/kwKBgQDR3fUkmEzj202bx8pHE97gxfTSd9aJAQN06uaz3GByjyKGnqB9\ni/mGjBnUdrCOj9+s5VT/ntK+qdSpdUODYuOBxiGxSnBK9kFpjTVHe35nYOHiLOHB\nIMPdhtGSUCzJNNvrpBzJ1ZM4SZwq2sSXWFRN9On7Amog0liJG5mpQqGxRQKBgHmP\nzFycF3XaZKH2xm8ppgg/FXBXJYEWMEr07+aJ7kEvWq4wHPAfSoCMe+JB6vDmg2Zr\nYgvdao7W5v83NKpQl5+LZrHNfTWAnxJviSWRQJyzD/Fqw7fZ5Is5K/SCDfn0aC+y\nxilSWhHDnFNM0Hr7KX3rLap43QJpePAk4qnF3AX7AoGBAOe5C1VMKoTapnxvo/FI\nBCvXw05SSEExfXVR0ryoqUxgu1asCkYyJSoWxOZQ+33npQ1/zV1mCXn/lNZcyveW\nZ5/cUw71grW8KBYFrW7LeQIzjZb7xPI3Z4EV0uYd2b69GkQk1buHj/gsswRhGEvx\nJM1DN1SCenbGcVLprM0vVelp\n-----END PRIVATE KEY-----\n",
"client_email": "firebase-adminsdk-pgjve@twistter-e4649.iam.gserviceaccount.com",
"client_id": "102241295911303209723",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-pgjve%40twistter-e4649.iam.gserviceaccount.com"
}

View File

@@ -1,5 +1,10 @@
This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).
Cloud: https://us-central1-twistter-e4649.cloudfunctions.net/api
Local: http://localhost:5001/twistter-e4649/us-central1/api (npm install --save firebase)
Below you will find some information on how to perform common tasks.<br> Below you will find some information on how to perform common tasks.<br>
You can find the most recent version of this guide [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md). You can find the most recent version of this guide [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md).

View File

@@ -61,6 +61,14 @@
} }
} }
}, },
"@material-ui/icons": {
"version": "4.5.1",
"resolved": "https://registry.npmjs.org/@material-ui/icons/-/icons-4.5.1.tgz",
"integrity": "sha512-YZ/BgJbXX4a0gOuKWb30mBaHaoXRqPanlePam83JQPZ/y4kl+3aW0Wv9tlR70hB5EGAkEJGW5m4ktJwMgxQAeA==",
"requires": {
"@babel/runtime": "^7.4.4"
}
},
"@material-ui/styles": { "@material-ui/styles": {
"version": "4.5.0", "version": "4.5.0",
"resolved": "https://registry.npmjs.org/@material-ui/styles/-/styles-4.5.0.tgz", "resolved": "https://registry.npmjs.org/@material-ui/styles/-/styles-4.5.0.tgz",
@@ -454,9 +462,9 @@
} }
}, },
"is-buffer": { "is-buffer": {
"version": "2.0.3", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz",
"integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A=="
} }
} }
}, },
@@ -5277,6 +5285,11 @@
"resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz",
"integrity": "sha1-OGchPo3Xm/Ho8jAMDPwe+xgsDfE=" "integrity": "sha1-OGchPo3Xm/Ho8jAMDPwe+xgsDfE="
}, },
"jwt-decode": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-2.2.0.tgz",
"integrity": "sha1-fYa9VmefWM5qhHBKZX3TkruoGnk="
},
"kind-of": { "kind-of": {
"version": "3.2.2", "version": "3.2.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
@@ -9712,6 +9725,11 @@
"resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c="
}, },
"typeface-roboto": {
"version": "0.0.75",
"resolved": "https://registry.npmjs.org/typeface-roboto/-/typeface-roboto-0.0.75.tgz",
"integrity": "sha512-VrR/IiH00Z1tFP4vDGfwZ1esNqTiDMchBEXYY9kilT6wRGgFoCAlgkEUMHb1E3mB0FsfZhv756IF0+R+SFPfdg=="
},
"uglify-js": { "uglify-js": {
"version": "3.4.10", "version": "3.4.10",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz",

View File

@@ -4,12 +4,14 @@
"private": true, "private": true,
"dependencies": { "dependencies": {
"@material-ui/core": "^4.4.3", "@material-ui/core": "^4.4.3",
"@material-ui/icons": "^4.5.1",
"@material-ui/styles": "^4.5.0", "@material-ui/styles": "^4.5.0",
"@material-ui/system": "^4.5.0", "@material-ui/system": "^4.5.0",
"axios": "^0.19.0", "axios": "^0.19.0",
"clsx": "^1.0.4", "clsx": "^1.0.4",
"create-react-app": "^3.1.2", "create-react-app": "^3.1.2",
"install": "^0.13.0", "install": "^0.13.0",
"jwt-decode": "^2.2.0",
"node-pre-gyp": "^0.13.0", "node-pre-gyp": "^0.13.0",
"react": "^16.9.0", "react": "^16.9.0",
"react-dom": "^16.9.0", "react-dom": "^16.9.0",
@@ -17,7 +19,8 @@
"react-router-dom": "^5.1.0", "react-router-dom": "^5.1.0",
"react-scripts": "0.9.5", "react-scripts": "0.9.5",
"redux": "^4.0.4", "redux": "^4.0.4",
"redux-thunk": "^2.3.0" "redux-thunk": "^2.3.0",
"typeface-roboto": "0.0.75"
}, },
"devDependencies": {}, "devDependencies": {},
"scripts": { "scripts": {

View File

@@ -1,3 +1,7 @@
html,
body {
background-color: rgb(245, 245, 245);
}
.app { .app {
font-family: "Segoe UI"; font-family: "Segoe UI";
font-size: large; font-size: large;
@@ -22,7 +26,7 @@
white-space: nowrap; white-space: nowrap;
} }
.register { .signup {
background-color: #1da1f2; background-color: #1da1f2;
border: 1px solid #fff; border: 1px solid #fff;
color: #fff; color: #fff;

View File

@@ -1,45 +1,87 @@
/* eslint-disable */ /* eslint-disable */
import React, { Component } from 'react'; import React, { Component } from "react";
import "./App.css";
import axios from "axios";
import './App.css'; import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import Navbar from "./components/layout/NavBar";
import jwtDecode from "jwt-decode";
// Redux
import { Provider } from "react-redux";
import store from "./redux/store";
import MuiThemeProvider from '@material-ui/core/styles/MuiThemeProvider'; import MuiThemeProvider from '@material-ui/core/styles/MuiThemeProvider';
import createMuiTheme from '@material-ui/core/styles/createMuiTheme'; import createMuiTheme from '@material-ui/core/styles/createMuiTheme';
import { BrowserRouter as Router } from 'react-router-dom';
import Route from 'react-router-dom/Route';
import Navbar from './components/layout/NavBar';
import themeObject from './util/theme'; import themeObject from './util/theme';
import { SET_AUTHENTICATED } from './redux/types';
import { logoutUser, getUserData } from './redux/actions/userActions';
// Components
import AuthRoute from "./util/AuthRoute";
// axios.defaults.baseURL = 'http://localhost:5006/twistter-e4649/us-central1/api';
// Pages
import home from './pages/Home'; import home from './pages/Home';
import register from './pages/Register'; import signup from './pages/Signup';
import login from './pages/Login'; import login from './pages/Login';
import user from './pages/user'; import user from './pages/user';
import logout from './pages/Logout';
import Delete from './pages/Delete';
import writeMicroblog from './Writing_Microblogs.js'; import writeMicroblog from './Writing_Microblogs.js';
import edit from './pages/edit.js'; import editProfile from './pages/editProfile';
import userLine from './Userline.js'; import userLine from './Userline.js';
const theme = createMuiTheme(themeObject); const theme = createMuiTheme(themeObject);
const token = localStorage.FBIdToken;
if (token) {
try {
const decodedToken = jwtDecode(token);
if (decodedToken.exp * 1000 < Date.now()) {
store.dispatch(logoutUser());
window.location.href = "/login";
} else {
store.dispatch({ type: SET_AUTHENTICATED });
axios.defaults.headers.common['Authorization'] = token;
store.dispatch(getUserData());
}
} catch (invalidTokenError) {
store.dispatch(logoutUser());
window.location.href = "/login";
}
}
class App extends Component { class App extends Component {
render() { render() {
return ( return (
<MuiThemeProvider theme={theme}> <MuiThemeProvider theme={theme}>
<Provider store={store}>
<Router> <Router>
<div className='container' > <div className='container' >
<Navbar /> <Navbar />
</div> </div>
<div className="app"> <div className="app">
<Route exact path="/" component={home}/> <Switch>
<Route exact path="/register" component={register}/> {/* AuthRoute checks if the user is logged in and if they are it redirects them to /home */}
<Route exact path="/login" component={login}/> <AuthRoute exact path="/signup" component={signup} />
<AuthRoute exact path="/login" component={login} />
<Route exact path="/logout" component={logout} />
<Route exact path="/delete" component={Delete} />
<Route exact path="/user" component={user} /> <Route exact path="/user" component={user} />
<Route exact path="/home" component={writeMicroblog} /> <Route exact path="/home" component={writeMicroblog} />
<Route exact path="/edit" component={edit}/> <Route exact path="/edit" component={editProfile} />
<Route exact path="/user" component={userLine}/>
<AuthRoute exact path="/" component={home}/>
</Switch>
</div> </div>
</Router> </Router>
</Provider>
</MuiThemeProvider> </MuiThemeProvider>
); );
} }

View File

@@ -1,22 +0,0 @@
/* eslint-disable */
import React, { Component} from 'react';
import './App.css';
import logo from './images/twistter-logo.png';
import TextField from '@material-ui/core/TextField';
class Logout extends Component {
render() {
return(
<div>
<img src={logo} className="app-logo" alt="logo" />
<br/><br/>
<b>Logout of your Twistter Account</b>
<br/><br/>
<br/><br/>
<button className="authButtons register" type="submit">Sign Out</button>
</div>
);
};
}
export default Logout;

View File

@@ -23,7 +23,7 @@ class Userline extends Component {
componentDidMount() { componentDidMount() {
axios.get('http://localhost:5001/twistter-e4649/us-central1/api/getallPostsforUser') axios.get('/getallPostsforUser')
.then(res => { .then(res => {
const post = res.data; const post = res.data;
this.setState({microBlogs : post}) this.setState({microBlogs : post})

View File

@@ -33,22 +33,27 @@ class Writing_Microblogs extends Component {
} }
handleSubmit(event) { handleSubmit(event) {
// alert('A title for the microblog was inputted: ' + this.state.title + '\nA microblog was posted: ' + this.state.value);
const response = axios.post( const postData = {
'http://localhost:5001/twistter-e4649/us-central1/api/putPost', body: this.state.value,
{ body: this.state.value,
userHandle: "new user",
userImage: "bing-url", userImage: "bing-url",
microBlogTitle: this.state.title, microBlogTitle: this.state.title,
microBlogTopics: this.state.topics.split(', ') microBlogTopics: this.state.topics.split(', ')
}
const headers = {
headers: { 'Content-Type': 'application/json'}
}
}, axios
{ headers: { 'Content-Type': 'application/json'} } .post("/putPost", postData, headers)
.then((res) =>{
) alert('Post was shared successfully!')
console.log(response.data); console.log(res.data);
alert('Post was shared successfully!'); })
.catch((err) => {
alert('An error occured.');
console.error(err);
})
event.preventDefault(); event.preventDefault();
this.setState({value: '', title: '',characterCount: 250, topics: ''}) this.setState({value: '', title: '',characterCount: 250, topics: ''})
} }

View File

@@ -1,31 +1,75 @@
/* eslint-disable */ /* eslint-disable */
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import PropTypes from 'prop-types';
// Material UI stuff
import AppBar from '@material-ui/core/AppBar'; import AppBar from '@material-ui/core/AppBar';
import ToolBar from '@material-ui/core/Toolbar'; import ToolBar from '@material-ui/core/Toolbar';
import Button from '@material-ui/core/Button'; import Button from '@material-ui/core/Button';
import withStyles from "@material-ui/core/styles/withStyles";
// Redux stuff
// import { logoutUser } from '../../redux/actions/userActions';
import { connect } from 'react-redux';
const styles = {
form: {
textAlign: "center"
},
textField: {
marginBottom: 30
},
pageTitle: {
marginBottom: 40
},
button: {
positon: "relative",
marginBottom: 30
},
progress: {
position: "absolute"
}
};
export class Navbar extends Component { export class Navbar extends Component {
render() { render() {
const authenticated = this.props.user.authenticated;
return ( return (
<AppBar> <AppBar>
<ToolBar> <ToolBar>
<Button component={ Link } to='/'> <Button component={ Link } to='/'>
Home Home
</Button> </Button>
<Button component={ Link } to='/login'> {!authenticated && <Button component={ Link } to='/login'>
Login Login
</Button> </Button>}
<Button component={ Link } to='/register'> {!authenticated && <Button component={ Link } to='/signup'>
Register Sign Up
</Button> </Button>}
<Button component={ Link } to='/logout'> {authenticated && <Button component={ Link } to='/logout'>
Logout Logout
</Button> </Button>}
{authenticated && <Button component={ Link } to='/delete'>
Delete Account
</Button>}
</ToolBar> </ToolBar>
</AppBar> </AppBar>
) )
} }
} }
export default Navbar; const mapStateToProps = (state) => ({
user: state.user
})
// const mapActionsToProps = { logoutUser };
Navbar.propTypes = {
user: PropTypes.object.isRequired,
classes: PropTypes.object.isRequired
}
export default connect(mapStateToProps)(withStyles(styles)(Navbar));
// export default Navbar;

View File

@@ -0,0 +1,48 @@
import React, { Component, Fragment } from "react";
import PropTypes from "prop-types";
import axios from "axios";
import { connect } from 'react-redux';
//MUI
import withStyles from "@material-ui/core/styles/withStyles";
import Card from "@material-ui/core/CardMedia";
import Typography from "@material-ui/core/Typography";
import Button from "@material-ui/core/Button";
import { Paper } from "@material-ui/core";
const styles = theme => ({
...theme
});
class Profile extends Component {
state = {
profile: null
};
componentDidMount() {
axios
.get("/user")
.then(res => {
console.log(res.data.userData.credentials.handle);
this.setState({
profile: res.data.userData.credentials.handle
});
})
.catch(err => console.log(err));
}
render() {
let profileMarkup = this.state.profile ? (
<p>
<Typography variant='h5'>{this.state.profile}</Typography>
</p>) : <p>loading profile...</p>
return profileMarkup;
}
}
const mapStateToProps = state => ({
user: state.user,
classes: PropTypes.object.isRequired
});
export default connect(mapStateToProps)(withStyles(styles)(Profile));

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View File

@@ -1,8 +1,11 @@
import React from 'react'; import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import App from './App'; import App from './App';
import * as serviceWorker from './serviceWorker';
ReactDOM.render( ReactDOM.render(
<App />, <App />,
document.getElementById('root') document.getElementById('root')
); );
serviceWorker.unregister();

View File

@@ -0,0 +1,60 @@
/* eslint-disable */
import React, { Component } from "react";
import PropTypes from "prop-types";
// Material UI stuff
import Button from "@material-ui/core/Button";
import withStyles from "@material-ui/core/styles/withStyles";
// Redux stuff
//import { logoutUser } from "../redux/actions/userActions";
import { deleteUser } from "../redux/actions/userActions";
import { connect } from "react-redux";
const styles = {
form: {
textAlign: "center"
},
textField: {
marginBottom: 30
},
pageTitle: {
marginBottom: 40
},
button: {
positon: "relative",
marginBottom: 30
},
progress: {
position: "absolute"
}
};
export class Delete extends Component {
componentDidMount() {
//this.props.logoutUser();
this.props.deleteUser();
this.props.history.push('/');
}
render() {
return null;
}
}
const mapStateToProps = (state) => ({
user: state.user
});
//const mapActionsToProps = { logoutUser };
const mapActionsToProps = { deleteUser };
Delete.propTypes = {
//logoutUser: PropTypes.func.isRequired,
deleteUser: PropTypes.func.isRequired,
user: PropTypes.object.isRequired,
classes: PropTypes.object.isRequired
};
export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Delete));

View File

@@ -21,8 +21,8 @@ class Home extends Component {
<div> <div>
<b>Join today or sign in if you already have an account.</b> <b>Join today or sign in if you already have an account.</b>
<br/><br/> <br/><br/>
<form action="./register"> <form action="./signup">
<button className="authButtons register">Sign up</button> <button className="authButtons signup">Sign up</button>
</form> </form>
<br/> <br/>
<form action="./login"> <form action="./login">

View File

@@ -1,73 +1,192 @@
/* eslint-disable */ /* eslint-disable */
import React, { Component } from 'react'; import React, { Component } from 'react';
import '../App.css'; // import '../App.css';
import axios from 'axios';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import logo from '../images/twistter-logo.png'; import logo from '../images/twistter-logo.png';
import TextField from '@material-ui/core/TextField';
class Login extends Component { // Material-UI stuff
import Button from "@material-ui/core/Button";
import CircularProgress from "@material-ui/core/CircularProgress";
import Grid from "@material-ui/core/Grid";
import TextField from "@material-ui/core/TextField";
import Typography from "@material-ui/core/Typography";
import withStyles from "@material-ui/core/styles/withStyles";
// Redux stuff
import { connect } from 'react-redux';
import { loginUser } from '../redux/actions/userActions';
import { fontFamily } from '@material-ui/system';
//Theme
const styles = {
form: {
textAlign: "center"
},
textField: {
marginBottom: 20
},
pageTitle: {
// marginTop: 20,
marginBottom: 40
},
button: {
positon: "relative",
marginBottom: 30
},
progress: {
position: "absolute"
},
p: {
fontFamily: "cursive",
}
};
export class Login extends Component {
// componentDidMount() {
// axios
// .get("/getProfileInfo")
// .then((res) => {
// this.setState({
// firstName: res.data.firstName,
// lastName: res.data.lastName,
// email: res.data.email,
// handle: res.data.handle,
// bio: res.data.bio
// });
// })
// .catch((err) => {
// console.error(err);
// });
// }
// Constructor for the state
constructor() { constructor() {
super(); super();
this.state = { this.state = {
email: '', email: "",
password: '', password:"",
errors: {} errors: {}
}; };
this.handleChange = this.handleChange.bind(this); }
this.handleSubmit = this.handleSubmit.bind(this);
}; componentWillReceiveProps(nextProps) {
if (nextProps.UI.errors) {
this.setState({ errors: nextProps.UI.errors });
}
}
// Runs whenever the submit button is clicked.
// Updates the database entry of the signed in user with the
// data stored in the state.
handleSubmit = (event) => { handleSubmit = (event) => {
event.preventDefault(); event.preventDefault();
const userData = { const loginData = {
email: this.state.email, email: this.state.email,
password: this.state.password password: this.state.password,
}; };
axios.post('http://localhost:5001/twistter-e4649/us-central1/api/login', userData) this.props.loginUser(loginData, this.props.history);
.then(res => {
console.log(res.data);
localStorage.setItem('firebaseIdToken', `Bearer ${res.data.token}`);
this.props.history.push('/home');
})
.catch(err => {
this.setState({
errors: err.response.data
});
});
}; };
// Updates the state whenever one of the textboxes changes.
// The key is the name of the textbox and the value is the
// value in the text box.
handleChange = (event) => { handleChange = (event) => {
this.setState({ this.setState({
[event.target.name]: event.target.value [event.target.name]: event.target.value,
errors: {
[event.target.name]: null
}
}); });
}; };
render() { render() {
const { classes } = this.props; const { classes, UI: { loading } } = this.props;
const { errors } = this.state; const { errors } = this.state;
return (
<div>
<img src={logo} className="app-logo" alt="logo" />
<br/><br/>
<b>Log in to Twistter</b>
<br/><br/>
<form noValidate onSubmit={this.handleSubmit}>
<TextField className="authInput" id="email" name="email" label="Email" helperText={errors.email} error={errors.email ? true : false}
value={this.state.email} onChange={this.handleChange} />
<br/><br/>
<TextField className="authInput" id="password" name="password" label="Password" helperText={errors.password} error={errors.password ? true : false}
value={this.state.password} onChange={this.handleChange} />
<br/><br/>
<button className="authButtons register" type="submit">Sign in</button> return (
<Grid container className={classes.form}>
<Grid item sm />
<Grid item sm>
<img src={logo} className="app-logo" alt="logo" />
<br></br>
<Typography variant="p" className={classes.pageTitle} fontFamily = "Georgia, serif">
<b>Log in to Twistter</b>
<br></br>
</Typography>
<br></br>
<form noValidate onSubmit={this.handleSubmit}>
<TextField
id="email"
name="email"
label="Email*"
className={classes.textField}
value={this.state.email}
helperText={errors.email}
error={errors.email ? true : false}
variant="outlined"
onChange={this.handleChange}
fullWidth
/>
<TextField
id="password"
name="password"
label="Password*"
className={classes.textField}
value={this.state.password}
helperText={errors.password}
error={errors.password ? true : false}
type="password"
variant="outlined"
onChange={this.handleChange}
fullWidth
/>
<Button
type="submit"
variant="contained"
color="primary"
className={classes.button}
disabled={loading}
>
Login
{loading && (
<CircularProgress size={30} className={classes.progress} />
)}
</Button>
{errors.general && (
<Typography color="error">Invalid username/email or password</Typography>
)}
</form> </form>
</div> </Grid>
<Grid item sm />
</Grid>
); );
};
} }
}
// Proptypes just confirms that all data in it exists and is of the type that it
// is declared to be
Login.propTypes = {
classes: PropTypes.object.isRequired,
loginUser: PropTypes.func.isRequired,
user: PropTypes.object.isRequired,
UI: PropTypes.object.isRequired
};
const mapStateToProps = (state) => ({
user: state.user,
UI: state.UI,
});
const mapActionsToProps = {
loginUser
}
Login.propTypes = { Login.propTypes = {
classes: PropTypes.object.isRequired classes: PropTypes.object.isRequired
}; };
// This mapStateToProps is just synchronizing the 'state' to 'this.props' so we can access it
// The state contains info about the current logged in user
export default Login; export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Login));

View File

@@ -0,0 +1,56 @@
/* eslint-disable */
import React, { Component } from "react";
import PropTypes from "prop-types";
// Material UI stuff
import Button from "@material-ui/core/Button";
import withStyles from "@material-ui/core/styles/withStyles";
// Redux stuff
import { logoutUser } from "../redux/actions/userActions";
import { connect } from "react-redux";
const styles = {
form: {
textAlign: "center"
},
textField: {
marginBottom: 30
},
pageTitle: {
marginBottom: 40
},
button: {
positon: "relative",
marginBottom: 30
},
progress: {
position: "absolute"
}
};
export class Logout extends Component {
componentDidMount() {
this.props.logoutUser();
this.props.history.push('/');
}
render() {
return null;
}
}
const mapStateToProps = (state) => ({
user: state.user
});
const mapActionsToProps = { logoutUser };
Logout.propTypes = {
logoutUser: PropTypes.func.isRequired,
user: PropTypes.object.isRequired,
classes: PropTypes.object.isRequired
};
export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Logout));

View File

@@ -1,97 +0,0 @@
import React, { Component } from 'react';
import '../App.css';
import logo from '../images/twistter-logo.png';
import axios from 'axios';
import TextField from '@material-ui/core/TextField';
import PropTypes from 'prop-types';
class Register extends Component {
constructor() {
super();
this.state = {
email: '',
handle: '',
password: '',
confirmPassword: '',
errors: {}
};
this.handleSubmit = this.handleSubmit.bind(this);
this.handleChange = this.handleChange.bind(this);
};
handleSubmit = (event) => {
const newUserData = {
email: this.state.email,
handle: this.state.handle,
password: this.state.password,
confirmPassword: this.state.confirmPassword
};
axios.post('http://localhost:5001/twistter-e4649/us-central1/api/signup', newUserData)
.then(res => {
console.log(res.data);
localStorage.setItem('firebaseIdToken', `Bearer ${res.data.token}`);
this.props.history.push('/');
})
.catch(err => {
this.setState({
errors: err.response.data
});
});
alert("You successfully registered");
event.preventDefault();
this.setState({email: '', handle: '', password: '', confirmPassword: ''});
};
handleChange = (event) => {
this.setState({
[event.target.name]: event.target.value
});
};
render() {
const { classes } = this.props;
const { errors } = this.state;
return (
<div>
<img src={logo} className="app-logo" alt="logo" />
<br/><br/>
<b>Create your account</b>
<br/><br/>
<form noValidate onSubmit={this.handleSubmit}>
<TextField className="authInput" id="email" name="email" label="Email" helperText={errors.email} error={errors.email ? true : false}
value={this.state.email} onChange={this.handleChange}/>
<br/><br/>
<TextField className="authInput" id="username" name="handle" label="Username" helperText={errors.handle} error={errors.handle ? true : false}
value={this.state.handle} onChange={this.handleChange} />
<br/><br/>
<TextField className="authInput" id="password" name="password" label="Password" helperText={errors.password} error={errors.password ? true : false}
value={this.state.password} onChange={this.handleChange} />
<br/><br/>
<TextField className="authInput" id="confirmPassword" name="confirmPassword" label="Confirm Password" helperText={errors.confirmPassword} error={errors.confirmPassword ? true : false}
value={this.state.confirmPassword} onChange={this.handleChange} />
<br/><br/>
{
errors.general &&
(<div className={classes.customError}>
{errors.general}
</div>)
}
<button class="authButtons register" id="submit">Sign up</button>
</form>
</div>
);
}
}
Register.propTypes = {
classes: PropTypes.object.isRequired
};
export default Register;

View File

@@ -0,0 +1,214 @@
/* eslint-disable */
import React, { Component } from 'react';
// import '../App.css';
import PropTypes from 'prop-types';
import logo from '../images/twistter-logo.png';
// Material-UI stuff
import Button from "@material-ui/core/Button";
import CircularProgress from "@material-ui/core/CircularProgress";
import Grid from "@material-ui/core/Grid";
import TextField from "@material-ui/core/TextField";
import Typography from "@material-ui/core/Typography";
import withStyles from "@material-ui/core/styles/withStyles";
// Redux stuff
import { connect } from 'react-redux';
import { signupUser } from '../redux/actions/userActions';
import { border } from '@material-ui/system';
const styles = {
form: {
textAlign: "center"
},
textField: {
marginBottom: 20,
//border: "1px solid #234",
display: "inline-block",
boxSizing: "border-box",
},
pageTitle: {
marginBottom: 40
},
button: {
positon: "relative",
marginBottom: 30
},
progress: {
position: "absolute"
},
div: {
borderRadius: "5px",
backgroundColor: "grey",
padding: "20px",
},
p: {
fontFamily: "Segoe UI",
}
};
export class Signup extends Component {
// Constructor for the state
constructor() {
super();
this.state = {
handle: "",
email: "",
password:"",
confirmPassword: "",
errors: {}
};
}
componentWillReceiveProps(nextProps) {
if (nextProps.UI.errors) {
this.setState({ errors: nextProps.UI.errors });
}
}
// Runs whenever the submit button is clicked.
// Updates the database entry of the signed in user with the
// data stored in the state.
handleSubmit = (event) => {
event.preventDefault();
const signupData = {
handle: this.state.handle,
email: this.state.email,
password: this.state.password,
confirmPassword: this.state.confirmPassword
};
console.log(signupData)
this.props.signupUser(signupData, this.props.history);
};
// Updates the state whenever one of the textboxes changes.
// The key is the name of the textbox and the value is the
// value in the text box.
handleChange = (event) => {
this.setState({
[event.target.name]: event.target.value,
errors: {
[event.target.name]: null
}
});
};
render() {
const { classes, UI: { loading } } = this.props;
const { errors } = this.state;
return (
<Grid container className={classes.form}>
<Grid item sm />
<Grid item sm>
<img src={logo} className="app-logo" alt="logo" />
<br></br>
<Typography variant="p" className={classes.pageTitle}>
<b>Create a new account</b>
<br></br>
</Typography>
<br></br>
<form noValidate onSubmit={this.handleSubmit}>
<TextField
id="handle"
name="handle"
label="Username*"
className={classes.textField}
value={this.state.handle}
helperText={errors.handle}
error={errors.handle ? true : false}
variant="outlined"
onChange={this.handleChange}
fullWidth
/>
<TextField
id="email"
name="email"
label="Email*"
className={classes.textField}
value={this.state.email}
helperText={errors.email}
error={errors.email ? true : false}
variant="outlined"
onChange={this.handleChange}
fullWidth
/>
<TextField
id="password"
name="password"
label="Password*"
className={classes.textField}
value={this.state.password}
helperText={errors.password}
error={errors.password ? true : false}
type="password"
variant="outlined"
onChange={this.handleChange}
fullWidth
/>
<TextField
id="confirmPassword"
name="confirmPassword"
label="Confirm Password*"
className={classes.textField}
value={this.state.confirmPassword}
helperText={errors.confirmPassword}
error={errors.confirmPassword ? true : false}
type="password"
variant="outlined"
onChange={this.handleChange}
fullWidth
/>
<br></br>
<br></br>
<Button
type="submit"
variant="contained"
color="primary"
className={classes.button}
disabled={loading}
>
Sign Up
{loading && (
<CircularProgress size={30} className={classes.progress} />
)}
</Button>
{errors.general && (
<Typography color="error">Invalid username/email or password</Typography>
)}
</form>
</Grid>
<Grid item sm />
</Grid>
);
}
}
// Proptypes just confirms that all data in it exists and is of the type that it
// is declared to be
Signup.propTypes = {
classes: PropTypes.object.isRequired,
signupUser: PropTypes.func.isRequired,
user: PropTypes.object.isRequired,
UI: PropTypes.object.isRequired
};
const mapStateToProps = (state) => ({
user: state.user,
UI: state.UI,
});
const mapActionsToProps = {
signupUser
}
Signup.propTypes = {
classes: PropTypes.object.isRequired
};
// This mapStateToProps is just synchronizing the 'state' to 'this.props' so we can access it
// The state contains info about the current logged in user
export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Signup));

View File

@@ -50,6 +50,12 @@ export class edit extends Component {
}) })
.catch((err) => { .catch((err) => {
console.error(err); console.error(err);
if (err.response.status === 403) {
alert("You are not logged in");
// TODO: Redirect them, to the profile they are trying to edit
// If they are on /itsjimmy/edit, they will be redirected to /itsjimmy
this.props.history.push('../');
}
}); });
} }
@@ -82,9 +88,18 @@ export class edit extends Component {
handle: this.state.handle, handle: this.state.handle,
bio: this.state.bio bio: this.state.bio
}; };
// Removes all keys from newProfileData that are empty, undefined, or null
Object.keys(newProfileData).forEach(key => {
if (newProfileData[key] === "" || newProfileData[key] === undefined || newProfileData[key] === null) {
delete newProfileData[key];
}
})
axios axios
.post("/updateProfileInfo", newProfileData) .post("/updateProfileInfo", newProfileData)
.then((res) => { .then((res) => {
console.log(res);
this.setState({ this.setState({
loading: false loading: false
}); });
@@ -92,6 +107,7 @@ export class edit extends Component {
// TODO: Need to redirect user to their profile page // TODO: Need to redirect user to their profile page
}) })
.catch((err) => { .catch((err) => {
console.log(err);
this.setState({ this.setState({
errors: err.response.data, errors: err.response.data,
loading: false loading: false
@@ -102,6 +118,7 @@ export class edit extends Component {
// Updates the state whenever one of the textboxes changes. // Updates the state whenever one of the textboxes changes.
// The key is the name of the textbox and the value is the // The key is the name of the textbox and the value is the
// value in the text box. // value in the text box.
// Also sets errors to null of textboxes that have been edited
handleChange = (event) => { handleChange = (event) => {
this.setState({ this.setState({
[event.target.name]: event.target.value, [event.target.name]: event.target.value,

View File

@@ -1,35 +1,124 @@
/* eslint-disable */ /* eslint-disable */
import React, { Component } from 'react'; import React, { Component } from 'react';
import PropTypes from 'prop-types';
import axios from 'axios';
//import '../App.css'; //import '../App.css';
import { makeStyles, styled } from '@material-ui/core/styles'; import { makeStyles, styled } from '@material-ui/core/styles';
import Grid from '@material-ui/core/Grid'; import Grid from '@material-ui/core/Grid';
import Card from '@material-ui/core/Card'; import Card from '@material-ui/core/Card';
import CardMedia from '@material-ui/core/CardMedia'; import Chip from '@material-ui/core/Chip';
import CardContent from '@material-ui/core/CardContent'; import Typography from "@material-ui/core/Typography";
import AddCircle from '@material-ui/icons/AddCircle';
import TextField from '@material-ui/core/TextField';
const PostCard = styled(Card)({ // component
background: 'linear-gradient(45deg, #1da1f2 90%)', import Userline from '../Userline';
border: 3, import noImage from '../images/no-img.png';
borderRadius: 3,
height:225, const MyChip = styled(Chip)({
width: 645, margin: 2,
padding: '0 30px', color: 'primary'
}); });
class user extends Component { class user extends Component {
state = {
profile: null,
imageUrl: null,
topics: null,
newTopic: null
};
handleDelete = (topic) => {
alert(`Delete topic: ${topic}!`);
}
handleAddCircle = () => {
axios.post('/putTopic', {
topic: this.state.newTopic
})
.then(function () {
location.reload();
})
.catch(function (err) {
console.log(err);
});
}
handleChange(event) {
this.setState({
newTopic: event.target.value
})
}
componentDidMount() {
axios
.get("/user")
.then(res => {
this.setState({
profile: res.data.credentials.handle,
imageUrl: res.data.credentials.imageUrl
});
})
.catch(err => console.log(err));
axios
.get("/getAllTopics")
.then(res => {
this.setState({
topics: res.data
})
})
.catch(err => console.log(err));
}
render() { render() {
const classes = this.props;
let profileMarkup = this.state.profile ? (
<p>
<Typography variant='h5'>{this.state.profile}</Typography>
</p>) : (<p>loading username...</p>);
let topicsMarkup = this.state.topics ? (
this.state.topics.map(topic => <MyChip
label={{topic}.topic.topic}
key={{topic}.topic.topicId}
onDelete={ (topic) => this.handleDelete(topic)}/>)
) : (<p> loading topics...</p>);
let imageMarkup = this.state.imageUrl ? (
<img
src={this.state.imageUrl}
height="250"
width="250"
/>
) : (<img src={noImage}/>);
return ( return (
<div> <Grid container spacing={16}>
<h1>User Profile</h1> <Grid item sm={8} xs={12}>
<br/><br/> <p>Post</p>
<PostCard>Some card and content</PostCard> </Grid>
<br/><br/> <Grid item sm={4} xs={12}>
</div> {imageMarkup}
) {profileMarkup}
{topicsMarkup}
<TextField
id="newTopic"
label="new topic"
defaultValue=""
margin="normal"
variant="outlined"
value={this.state.newTopic}
onChange={ (event) => this.handleChange(event)}
/>
<AddCircle
color="primary"
clickable
onClick={this.handleAddCircle}
/>
</Grid>
</Grid>
);
} }
} }
export default user; export default user;

View File

@@ -0,0 +1,88 @@
import {SET_USER, SET_ERRORS, CLEAR_ERRORS, LOADING_UI, SET_AUTHENTICATED, SET_UNAUTHENTICATED} from '../types';
import axios from 'axios';
export const getUserData = () => (dispatch) => {
axios.get('/user')
.then((res) => {
dispatch({
type: SET_USER,
payload: res.data,
})
})
.catch((err) => console.error(err));
}
export const loginUser = (loginData, history) => (dispatch) => {
dispatch({ type: LOADING_UI });
axios
.post("/login", loginData)
.then((res) => {
// Save the login token
setAuthorizationHeader(res.data.token);
dispatch(getUserData());
dispatch({ type: CLEAR_ERRORS })
// Redirects to home page
history.push('/home');
})
.catch((err) => {
dispatch ({
type: SET_ERRORS,
payload: err.response.data,
})
});
};
export const signupUser = (newUserData, history) => (dispatch) => {
dispatch({ type: LOADING_UI });
axios
.post("/signup", newUserData)
.then((res) => {
console.log(res);
console.log(res.data);
// Save the signup token
setAuthorizationHeader(res.data.token);
dispatch(getUserData());
dispatch({ type: CLEAR_ERRORS })
// Redirects to home page
history.push('/home');
})
.catch((err) => {
dispatch ({
type: SET_ERRORS,
payload: err.response.data,
})
});
};
export const logoutUser = () => (dispatch) => {
localStorage.removeItem('FBIdToken');
delete axios.defaults.headers.common['Authorization'];
dispatch({ type: SET_UNAUTHENTICATED });
}
export const deleteUser = () => (dispatch) => {
axios
.delete("/delete")
.then((res) => {
console.log(res);
console.log("User account successfully deleted.");
}
)
.catch((err) => {
dispatch ({
type: SET_ERRORS,
payload: err.response.data,
})
});
localStorage.removeItem('FBIdToken');
delete axios.defaults.headers.common['Authorization'];
dispatch({ type: SET_UNAUTHENTICATED });
}
const setAuthorizationHeader = (token) => {
const FBIdToken = `Bearer ${token}`;
localStorage.setItem('FBIdToken', FBIdToken);
axios.defaults.headers.common['Authorization'] = FBIdToken;
}

View File

@@ -0,0 +1,30 @@
import { SET_ERRORS, CLEAR_ERRORS, LOADING_UI } from '../types';
const initialState = {
loading: false,
errors: null
};
export default function(state = initialState, action) {
switch(action.type) {
case SET_ERRORS:
return {
...state,
loading: false,
errors: action.payload
};
case CLEAR_ERRORS:
return {
...state,
loading: false,
errors: null
};
case LOADING_UI:
return {
...state,
loading: true
}
default:
return state;
}
}

View File

@@ -0,0 +1,28 @@
import {SET_USER, SET_ERRORS, CLEAR_ERRORS, LOADING_UI, SET_AUTHENTICATED, SET_UNAUTHENTICATED} from '../types';
const initialState = {
authenticated: false,
credentials: {},
likes: [],
notifications: []
};
export default function(state = initialState, action) {
switch(action.type) {
case SET_AUTHENTICATED:
return {
...state,
authenticated: true,
};
case SET_UNAUTHENTICATED:
return initialState;
case SET_USER:
return {
authenticated: true,
...action.payload,
};
default:
return state;
}
}

View File

@@ -0,0 +1,28 @@
import { createStore, combineReducers, applyMiddleware, compose } from "redux";
import thunk from "redux-thunk";
import userReducer from "./reducers/userReducer";
import dataReducer from "./reducers/dataReducer";
import uiReducer from "./reducers/uiReducer";
const initialState = {};
const middleWare = [thunk];
const reducers = combineReducers({
user: userReducer,
data: dataReducer,
UI: uiReducer
});
const store = createStore(
reducers,
initialState,
compose(
applyMiddleware(...middleWare),
window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : f => f // Can be removed after debugging is finished
)
);
export default store;

View File

@@ -0,0 +1,12 @@
// User reducer types
export const SET_AUTHENTICATED = 'SET_AUTHENTICATED';
export const SET_UNAUTHENTICATED = 'SET_UNAUTHENTICATED';
export const SET_USER = 'SET_USER';
export const LOADING_USER = 'LOADING_USER';
// UI reducer types
export const SET_ERRORS = 'SET_ERRORS';
export const LOADING_UI = 'LOADING_UI';
export const CLEAR_ERRORS = 'CLEAR_ERRORS';
// Data reducer types

View File

@@ -0,0 +1,135 @@
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://bit.ly/CRA-PWA
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://bit.ly/CRA-PWA'
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch(error => {
console.error('Error during service worker registration:', error);
});
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
);
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(registration => {
registration.unregister();
});
}
}

View File

@@ -0,0 +1,23 @@
import React from 'react';
import { Route, Redirect } from 'react-router-dom';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
const AuthRoute = ({ component: Component, authenticated, ...rest }) => (
<Route
{...rest}
render={(props) =>
authenticated === true ? <Redirect to="/home" /> : <Component {...props} />
}
/>
);
const mapStateToProps = (state) => ({
authenticated: state.user.authenticated
});
AuthRoute.propTypes = {
user: PropTypes.object
};
export default connect(mapStateToProps)(AuthRoute);

View File

@@ -50,7 +50,13 @@ export default {
marginBottom: 20 marginBottom: 20
}, },
paper: { paper: {
padding: 20 padding: 10,
display: 'flex',
justifyContent: 'center',
flexWrap: 'wrap'
},
chip: {
margin: 0.5,
}, },
profile: { profile: {
'& .image-wrapper': { '& .image-wrapper': {