Skip to content

Fixed #108: Add Log-in system to allow only the author delete his/her post#144

Merged
Pranav016 merged 20 commits intoALPHAVIO:developfrom
Subhra264:development
Feb 11, 2021
Merged

Fixed #108: Add Log-in system to allow only the author delete his/her post#144
Pranav016 merged 20 commits intoALPHAVIO:developfrom
Subhra264:development

Conversation

@Subhra264
Copy link
Copy Markdown

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]:

  • Have you followed the Contribution Guidelines while contributing.
  • Have you checked there aren't other open Pull Requests for the same update/change?
  • [] Have you made corresponding changes to the documentation?
  • Your submission doesn't break any existing feature.
  • Have you tested the code before submission?

Screenshots or Video:

NA

@Pranav016
Copy link
Copy Markdown
Member

Pranav016 commented Feb 8, 2021

Can you change base branch to develop ?
Click edit button and you'll be able to do that

image

Copy link
Copy Markdown
Member

@Pranav016 Pranav016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few changes required

Daily.Journal.-.Google.Chrome.2021-02-08.22-29-13.mp4

Comment on lines +121 to +125
app.get("/compose", auth, function(req, res){
const user = req.user;
if(!user){
return res.status(401).redirect("/log-in");
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!");
Copy link
Copy Markdown
Member

@Pranav016 Pranav016 Feb 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Pranav016
Copy link
Copy Markdown
Member

Pranav016 commented Feb 8, 2021

  • Also let me know should I use a random secret key or any recommendations for a good key. Let me know on discord.
  • Solve the merge conflicts as well

@Pranav016
Copy link
Copy Markdown
Member

Pranav016 commented Feb 10, 2021

I want to suggest something, always follow best practices for commit messages..

Fix merge conflicts
Resolve merge conflicts

there are two commits for solving merge conflicts which is not ideal

Also be specific with your commit messages, this message is incorrect Fix some bugs. And there are 9 commits in the PR and a few are redundant.

I'll review the PR this time but take care of this next time.

Copy link
Copy Markdown
Member

@Pranav016 Pranav016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
    image

res.cookie("token", token, {
httpOnly: true
});
res.redirect("/");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redirect to compose route after sign-up or login completed.

httpOnly: true
});

res.redirect("/");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

compose route.

@Subhra264 Subhra264 changed the base branch from master to develop February 11, 2021 06:07
Copy link
Copy Markdown
Member

@Pranav016 Pranav016 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work

@Pranav016 Pranav016 merged commit d2b4e36 into ALPHAVIO:develop Feb 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants