Skip to content

Adding likes backend #54

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e64a817
adding comments to controllers and models
josephburgess Feb 6, 2023
39091ab
Added cypress:open script to package
tmccoy99 Feb 7, 2023
23cb109
test driving timestamps in postschema
josephburgess Feb 7, 2023
53f24b2
test driving user_id field for posts
josephburgess Feb 7, 2023
713cb90
creating post first test passed
tomrolfe20 Feb 7, 2023
e3be822
amending tests given that user_id is required
josephburgess Feb 7, 2023
4526e72
added a function to clear message after submit
tomrolfe20 Feb 7, 2023
2096ef2
added user id to posts
tomrolfe20 Feb 7, 2023
8c268e3
add navigation bar
terrybro66 Feb 7, 2023
ea10a6a
updating tests
josephburgess Feb 7, 2023
f9fa5a9
added tokens and id error
tomrolfe20 Feb 7, 2023
a46c813
Merge pull request #1 from tmccoy99/post-backend-schema-updates
orhankhanbayov Feb 7, 2023
9669235
Merge pull request #2 from tmccoy99/navbar
josephburgess Feb 7, 2023
b7c5d89
Added testing + return ID on submit
ShaunFlood Feb 7, 2023
52397db
Merge branch 'main' into addingCreatePostForm
ShaunFlood Feb 7, 2023
7af9656
Merge pull request #3 from tmccoy99/addingCreatePostForm
terrybro66 Feb 7, 2023
93bf24b
sanity check
orhankhanbayov Feb 7, 2023
d22d86c
one test failing
orhankhanbayov Feb 8, 2023
8aa94b3
all tests passing with new profile page controller and routes
orhankhanbayov Feb 8, 2023
47d9006
Adding reloading posts
tomrolfe20 Feb 8, 2023
6f510e4
improved test names for better readability in e2e tests
tomrolfe20 Feb 8, 2023
762447c
add styling to the navbar links
terrybro66 Feb 8, 2023
e911f16
Refactored tests to use cy.login() command
tmccoy99 Feb 8, 2023
5c9e0ff
Merge pull request #4 from tmccoy99/addingReloadPosts
tmccoy99 Feb 8, 2023
297d5c4
all tests passing
orhankhanbayov Feb 8, 2023
ab98880
adding missing image to repo
terrybro66 Feb 8, 2023
c15247c
changed profile page to account
orhankhanbayov Feb 8, 2023
f64f37b
Merge pull request #5 from tmccoy99/navbar-styling
orhankhanbayov Feb 8, 2023
b64caba
Got the god dam bug
tomrolfe20 Feb 8, 2023
cebd1f4
Merge branch 'main' into test
tomrolfe20 Feb 8, 2023
fa8eac1
Merge pull request #6 from tmccoy99/test
tmccoy99 Feb 8, 2023
5fb5bae
adding user image upload functionality
josephburgess Feb 8, 2023
c65f690
removing unneccessary line of code
josephburgess Feb 8, 2023
a8ae115
increasing filesize to 15mb
josephburgess Feb 8, 2023
e84fbbe
Merge branch 'main' into user-model-updates
josephburgess Feb 8, 2023
b177157
removing further redundant code
josephburgess Feb 8, 2023
99463ee
one more redundant require
josephburgess Feb 8, 2023
4ae7508
all tests passing for update and delete methods
orhankhanbayov Feb 9, 2023
723662d
Merge pull request #8 from tmccoy99/delete-update
josephburgess Feb 9, 2023
2ce2fe0
Merge branch 'main' into user-model-updates
ShaunFlood Feb 9, 2023
d716bf8
Merge pull request #7 from tmccoy99/user-model-updates
tomrolfe20 Feb 9, 2023
fc481f0
testing completed for likes
ShaunFlood Feb 9, 2023
5c5b289
First test for unlike
ShaunFlood Feb 10, 2023
deb6fb2
second test completed
ShaunFlood Feb 10, 2023
ef9efca
testing completed
ShaunFlood Feb 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added user id to posts
tomrolfe20 committed Feb 7, 2023
commit 2096ef2c1a8572b48b64223e05aec074fc87127f
19 changes: 9 additions & 10 deletions api/controllers/tokens.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
const User = require("../models/user");
const TokenGenerator = require("../models/token_generator")
const User = require('../models/user');
const TokenGenerator = require('../models/token_generator');

const SessionsController = {

Create: (req, res) => {
const email = req.body.email;
const password = req.body.password;

User.findOne({ email: email }).then(async (user) => {
if (!user) {
console.log("auth error: user not found")
res.status(401).json({ message: "auth error" });
console.log('auth error: user not found');
res.status(401).json({ message: 'auth error' });
} else if (user.password !== password) {
console.log("auth error: passwords do not match")
res.status(401).json({ message: "auth error" });
console.log('auth error: passwords do not match');
res.status(401).json({ message: 'auth error' });
} else {
const token = await TokenGenerator.jsonwebtoken(user.id)
res.status(201).json({ token: token, message: "OK" });
const token = await TokenGenerator.jsonwebtoken(user.id);
res.status(201).json({ token: token, message: 'OK', user_id: user.id });
}
});
}
},
};

module.exports = SessionsController;
1 change: 1 addition & 0 deletions api/controllers/users.js
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ const UsersController = {
res.status(400).json({message: 'Bad request'})
} else {
res.status(201).json({ message: 'OK' });

}
});
},