Fixed #108: Add Log-in system to allow only the author delete his/her post#144
Fixed #108: Add Log-in system to allow only the author delete his/her post#144Pranav016 merged 20 commits intoALPHAVIO:developfrom
Conversation
Update font styles
…monojit docs: add mcmonojit as a contributor
Pranav016
left a comment
There was a problem hiding this comment.
Few changes required
Daily.Journal.-.Google.Chrome.2021-02-08.22-29-13.mp4
| app.get("/compose", auth, function(req, res){ | ||
| const user = req.user; | ||
| if(!user){ | ||
| return res.status(401).redirect("/log-in"); | ||
| } |
There was a problem hiding this comment.
When I am not a user and I press on compose, give an option to sign up or login. When I was testing the website, I wasn't able to compose since no sign up button was there for new user.
|
|
||
| User.findById(payload._id, (err, user) => { | ||
| if(err){ | ||
| return res.status(422).json("Oops! something went wrong!"); |
There was a problem hiding this comment.
When the username or password is incorrect or any error is there in sign up, don't redirect to a new page with error message returned in json or if you are redirecting, give a button again for login or sign up. But my recommendation would be just a show a popup for the message instead of redirecting since that helps retain the info and you don't have to enter again.
|
Align dark mode button to left corner
Add dependabot auto merge
…nto development
|
I want to suggest something, always follow best practices for commit messages.. there are two commits for solving merge conflicts which is not ideal Also be specific with your commit messages, this message is incorrect I'll review the PR this time but take care of this next time. |
There was a problem hiding this comment.
Very good work, a couple changes required.
- Show a logout button if user is already logged-in
- If user is already logged in, don't show the name option while commenting on posts, instead use their name from the database. (This is an optional feature for now, can be completed via a new issue, You can raise a new one after this PR is merged) but this will be fairly easy, just use JavaScript If-else and embed it into the html file using ejs. Update- Don't work on this right now, I'll raise a new issue for this later.
- Change base branch of the PR to develop

routes/user.router.js
Outdated
| res.cookie("token", token, { | ||
| httpOnly: true | ||
| }); | ||
| res.redirect("/"); |
There was a problem hiding this comment.
redirect to compose route after sign-up or login completed.
routes/user.router.js
Outdated
| httpOnly: true | ||
| }); | ||
|
|
||
| res.redirect("/"); |

What is the change?
Users now can sign up and log in to compose or delete a post. Only, authorized user( Author of the post ) can delete his/her post. The developers now have to add a "SECRET_KEY" in the .env file.
Related issue?
issue: #108
How was it tested?
Using PostMan and by manually testing
Checklist:
Before you create this PR, confirm all the requirements listed below by checking the checkboxes
[x]:Screenshots or Video:
NA