Skip to content
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

#164489929 create user profile #29

Merged
merged 1 commit into from
Apr 12, 2019
Merged

Conversation

Paccy10
Copy link

@Paccy10 Paccy10 commented Apr 9, 2019

What does this PR do?

This PR adds the functionality of creating a user profile

Description of Task to be completed?

  • creates GET: /api/users/:id/profile endpoint for getting a user profile
  • creates PUT :/api/users/:id/profile endpoint for updating a user profile
  • creates tests for GET: /api/users/:id/profile endpoint
  • creates tests for PUT :/api/users/:id/profile endpoint

How should this be manually tested?

  • go to postman and type http://localhost:3000/api/users/:id/profile (replace :id with the id of the user you want to view his profile), then send and you will get the profile
  • If you want to change your profile, go to postman and type http://localhost:3000/api/users/:id/profile (replace :id with your id), then add in the body what you want to update like username, bio or image and send, your profile will be updated.

What are the relevant pivotal tracker stories?

#164489929

Screenshots (if appropriate)

Response

Screen Shot 2019-04-09 at 15 25 29

@Paccy10 Paccy10 added the WIP label Apr 9, 2019
@Paccy10 Paccy10 force-pushed the ft-create-user-profile-164489929 branch from f3cff02 to 74da9d1 Compare April 9, 2019 14:38
};
const updatedUser = await User.update(
profile, { where: { id }, returning: true, plain: true }
);

Choose a reason for hiding this comment

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

Unexpected newline before ')' function-paren-newline

bio: req.body.bio ? req.body.bio : foundUser.bio,
image: req.file ? req.file.url : foundUser.image
};
const updatedUser = await User.update(

Choose a reason for hiding this comment

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

Unexpected newline after '(' function-paren-newline

@Paccy10 Paccy10 force-pushed the ft-create-user-profile-164489929 branch from 74da9d1 to 20c78fd Compare April 9, 2019 14:54
image: req.file ? req.file.url : foundUser.image
};
const updatedUser = await User.update(profile,
{ where: { id }, returning: true, plain: true });

Choose a reason for hiding this comment

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

Expected a newline before ')' function-paren-newline

bio: req.body.bio ? req.body.bio : foundUser.bio,
image: req.file ? req.file.url : foundUser.image
};
const updatedUser = await User.update(profile,

Choose a reason for hiding this comment

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

Expected a newline after '(' function-paren-newline

@Paccy10 Paccy10 force-pushed the ft-create-user-profile-164489929 branch 2 times, most recently from 1daae43 to 37c737a Compare April 9, 2019 15:32
bio: req.body.bio ? req.body.bio : foundUser.bio,
image: req.file ? req.file.url : foundUser.image
},
{ where: { id }, returning: true, plain: true });

Choose a reason for hiding this comment

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

Expected a newline before ')' function-paren-newline

const id = parseInt(req.params.id, 10);
const foundUser = await User.findOne({ where: { id } });
if (foundUser) {
const updatedUser = await User.update({

Choose a reason for hiding this comment

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

Expected a newline after '(' function-paren-newline

@Paccy10 Paccy10 force-pushed the ft-create-user-profile-164489929 branch from 37c737a to 8528837 Compare April 9, 2019 16:17
@blaisebakundukize
Copy link
Contributor

blaisebakundukize commented Apr 10, 2019

Good work @Paccy10, I appreciate the way you handled your tasks. But I realized that you are passing user_id in the endpoint for updating the user's profile. I think you don't need to add user_id in the URL because we already have it in the token. As long as we are using Passport, you can access that user_id from user's requests. So you do not need that middleware for checking user account because it compares both user_id from token and URL. For example: const userId = req.user.id;

@Paccy10 Paccy10 force-pushed the ft-create-user-profile-164489929 branch from 8528837 to 00483e2 Compare April 10, 2019 09:30
test/1-user.js Outdated
invalidToken,
validToken,
profile1,
profile2

Choose a reason for hiding this comment

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

'profile2' is defined but never used no-unused-vars

@Paccy10 Paccy10 force-pushed the ft-create-user-profile-164489929 branch from 00483e2 to 00d78a1 Compare April 10, 2019 09:41
@Paccy10 Paccy10 changed the title Feature(profile): User profile #164489929 create user profile Apr 10, 2019
@Paccy10 Paccy10 force-pushed the ft-create-user-profile-164489929 branch from 00d78a1 to a2de2d5 Compare April 10, 2019 13:59
@Paccy10 Paccy10 force-pushed the ft-create-user-profile-164489929 branch 2 times, most recently from 3d6895c to 185920a Compare April 11, 2019 12:12
import app from '../index';
import {
signup1,
signup3,

Choose a reason for hiding this comment

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

'signup3' is defined but never used no-unused-vars

@Paccy10 Paccy10 force-pushed the ft-create-user-profile-164489929 branch 2 times, most recently from ae76ff7 to 01e3de6 Compare April 11, 2019 12:50
@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-29 April 11, 2019 12:51 Inactive
@ruganda
Copy link
Contributor

ruganda commented Apr 12, 2019

@Paccy10 , Please fix these merge conflicts

@Paccy10 Paccy10 force-pushed the ft-create-user-profile-164489929 branch from 01e3de6 to 46d257d Compare April 12, 2019 07:59
@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-29 April 12, 2019 07:59 Inactive
@Paccy10 Paccy10 force-pushed the ft-create-user-profile-164489929 branch from 46d257d to 0eae920 Compare April 12, 2019 08:44
@itsgratien itsgratien temporarily deployed to badass-ah-backend-stagin-pr-29 April 12, 2019 08:44 Inactive
-getting user profile
-editing user profile

[Delivers #164489929]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants