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

#167484590: create user profiles upon successful registration #18

Merged
merged 2 commits into from
Aug 15, 2019

Conversation

raymond42
Copy link
Collaborator

@raymond42 raymond42 commented Aug 13, 2019

What does this PR do?

It implements:

  • getting user profile
  • update user's profile

Description of Task to be done?

  1. Adding profile.js file in controller directory
  2. Adding editProfile.js file in middleware directory
  3. Adding userprofile.test.js file in test directory
  4. Adding cloudinary to save our photos

How should this be manually tested?

  1. Clone this branch.
  2. Do npm install
  3. Create an account by signing up using localhost:3000/api/v1/users using POST method.
    4.- add this env variable for cloudinary into your dotenv
    • cloudinarySecretKey
    • cloudinaryApiKey
    • cloudinaryName
  4. Using your username and token update your profile using this route localhost:3000/api/v1/profile/username using PUT method.
    using formdata you can update the following information with this example:
  • userName: "ray32",
  • bio: "Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old",
  • image: upload image file

What are the relevant pivotal tracker stories?


create user profiles upon successful registration

screen shots

Screen Shot 2019-08-13 at 05 42 07

Screen Shot 2019-08-13 at 05 43 00

src/tests/userprofile.test.js Show resolved Hide resolved
@@ -0,0 +1,17 @@
import model from '../sequelize/models';
Copy link

Choose a reason for hiding this comment

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

Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

@@ -0,0 +1,110 @@
import { config } from 'dotenv';
Copy link

Choose a reason for hiding this comment

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

Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

@@ -0,0 +1,48 @@
import passport from 'passport';
Copy link

Choose a reason for hiding this comment

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

Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

@raymond42 raymond42 temporarily deployed to codinggeeks-ah-backnd-st-pr-18 August 13, 2019 03:40 Inactive
import { User } from '../sequelize/models';

config();
cloudinary.config({
Copy link
Contributor

Choose a reason for hiding this comment

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

This cloudinary config would be better if you put it in config folder. And rename the name of this controller to profileController

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

on it. thanks

src/helpers/schema/validationRules.js Show resolved Hide resolved

if (trueUsername !== suggestedUsername) {
return res.status(403).send({
error: 'sorry! you can not edit the profile that is not yours'
Copy link
Contributor

Choose a reason for hiding this comment

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

For this error message. I think it'd be better if the message started with a capital letter and instead of can not, cannot would be a better option in this case Reference to this article

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

on it. thanks

Copy link
Contributor

@malaba6 malaba6 left a comment

Choose a reason for hiding this comment

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

I have noticed that actually, you can upload a picture twice. Well, that is disastrous for our account because we are using a limited subscription. If you could make sure that when the user uploads a picture, it checks if the picture already exists. if so, it just uses the uploaded one.

@raymond42
Copy link
Collaborator Author

raymond42 commented Aug 13, 2019

I have noticed that actually, you can upload a picture twice. Well, that is disastrous for our account because we are using a limited subscription. If you could make sure that when the user uploads a picture, it checks if the picture already exists. if so, it just uses the uploaded one.

yes, you are right. let me implement that. thanks

cloud_name: process.env.cloudinaryName,
api_key: process.env.cloudinaryApiKey,
api_secret: process.env.cloudinarySecretKey,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be good that we all adhere to the convention on naming environment variable by using _ instead of camel case like in this case.
Screen Shot 2019-08-13 at 14 45 02
So instead of cloudinaryName, u can use CLOUDINARY_NAME

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it would be good that we all adhere to the convention on naming environment variable by using _ instead of camel case like in this case.
Screen Shot 2019-08-13 at 14 45 02
So instead of cloudinaryName, u can use CLOUDINARY_NAME

Thank you. On it now

Copy link
Contributor

@placideirandora placideirandora left a comment

Choose a reason for hiding this comment

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

  1. You should use the same route parameter name for consistency. You should use the one in lower case: username.

Screen Shot 2019-08-13 at 10 51 19

  1. You should capitalize the variable name: userfound as userFound because it is made up with 2 words.

Screen Shot 2019-08-13 at 14 42 23

  1. I think you should protect the route for retrieving a user profile because I was able to retrieve the route without having logged in.

Screen Shot 2019-08-13 at 14 47 42

  1. I think you should remove the status as we agreed. This error message got triggered when I tried to update my profile.

Screen Shot 2019-08-13 at 14 46 20

  1. You should remove those purple characters for the error message to be easily read.

Screen Shot 2019-08-13 at 14 59 02

@raymond42
Copy link
Collaborator Author

raymond42 commented Aug 13, 2019

  1. You should use the same route parameter name for consistency. You should use the one in lower case: username.
Screen Shot 2019-08-13 at 10 51 19
  1. You should capitalize the variable name: userfound as userFound because it is made up with 2 words.
Screen Shot 2019-08-13 at 14 42 23
  1. I think you should protect the route for retrieving a user profile because I was able to retrieve the route without having logged in.
Screen Shot 2019-08-13 at 14 47 42
  1. I think you should remove the status as we agreed. This error message got triggered when I tried to update my profile.
Screen Shot 2019-08-13 at 14 46 20
  1. You should remove those purple characters for the error message to be easily read.
Screen Shot 2019-08-13 at 14 59 02

thanks for the feedback. I am going to work on them. However, on feedback number 3, I think It's not necessary to protect the route because you are limiting the user to get the other profiles of the people. If a person could get or read other people's article also he should be able to get their profiles. And on feedback 4, because It's not me who worked on authentications, I did not want to touch into other people's file. So We agreed with the TTL to make the chore of cleaning up the codebase

@raymond42 raymond42 temporarily deployed to codinggeeks-ah-backnd-st-pr-18 August 13, 2019 16:01 Inactive
@@ -0,0 +1,110 @@
import { config } from 'dotenv';
Copy link

Choose a reason for hiding this comment

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

Parsing error: 'import' and 'export' may appear only with 'sourceType: module'

@raymond42 raymond42 temporarily deployed to codinggeeks-ah-backnd-st-pr-18 August 13, 2019 16:07 Inactive
@raymond42 raymond42 temporarily deployed to codinggeeks-ah-backnd-st-pr-18 August 13, 2019 16:16 Inactive
@raymond42 raymond42 temporarily deployed to codinggeeks-ah-backnd-st-pr-18 August 13, 2019 16:24 Inactive
@placideirandora
Copy link
Contributor

  1. You should use the same route parameter name for consistency. You should use the one in lower case: username.
Screen Shot 2019-08-13 at 10 51 19
  1. You should capitalize the variable name: userfound as userFound because it is made up with 2 words.
Screen Shot 2019-08-13 at 14 42 23
  1. I think you should protect the route for retrieving a user profile because I was able to retrieve the route without having logged in.
Screen Shot 2019-08-13 at 14 47 42
  1. I think you should remove the status as we agreed. This error message got triggered when I tried to update my profile.
Screen Shot 2019-08-13 at 14 46 20
  1. You should remove those purple characters for the error message to be easily read.
Screen Shot 2019-08-13 at 14 59 02

thanks for the feedback. I am going to work on them. However, on feedback number 3, I think It's not necessary to protect the route because you are limiting the user to get the other profiles of the people. If a person could get or read other people's article also he should be able to get their profiles. And on feedback 4, because It's not me who worked on authentications, I did not want to touch into other people's file. So We agreed with the TTL to make the chore of cleaning up the codebase

About the feedback 3, The user will be able to retrieve other user's profiles as long as they have logged in. Therefore, Protecting the route will not block the user from retrieving others' profiles.

About the feedback 4, You are allowed to do that because I also did it when I removed the status messages from Malaba's user controller. I think it is okay.

@raymond42
Copy link
Collaborator Author

raymond42 commented Aug 14, 2019

  1. You should use the same route parameter name for consistency. You should use the one in lower case: username.
Screen Shot 2019-08-13 at 10 51 19
  1. You should capitalize the variable name: userfound as userFound because it is made up with 2 words.
Screen Shot 2019-08-13 at 14 42 23
  1. I think you should protect the route for retrieving a user profile because I was able to retrieve the route without having logged in.
Screen Shot 2019-08-13 at 14 47 42
  1. I think you should remove the status as we agreed. This error message got triggered when I tried to update my profile.
Screen Shot 2019-08-13 at 14 46 20
  1. You should remove those purple characters for the error message to be easily read.
Screen Shot 2019-08-13 at 14 59 02

thanks for the feedback. I am going to work on them. However, on feedback number 3, I think It's not necessary to protect the route because you are limiting the user to get the other profiles of the people. If a person could get or read other people's article also he should be able to get their profiles. And on feedback 4, because It's not me who worked on authentications, I did not want to touch into other people's file. So We agreed with the TTL to make the chore of cleaning up the codebase

About the feedback 3, The user will be able to retrieve other user's profiles as long as they have logged in. Therefore, Protecting the route will not block the user from retrieving others' profiles.

About the feedback 4, You are allowed to do that because I also did it when I removed the status messages from Malaba's user controller. I think it is okay.

@placideirandora I talked to TTL about this. and we agreed to make a chore of doing that

@placideirandora
Copy link
Contributor

  1. You should use the same route parameter name for consistency. You should use the one in lower case: username.
Screen Shot 2019-08-13 at 10 51 19
  1. You should capitalize the variable name: userfound as userFound because it is made up with 2 words.
Screen Shot 2019-08-13 at 14 42 23
  1. I think you should protect the route for retrieving a user profile because I was able to retrieve the route without having logged in.
Screen Shot 2019-08-13 at 14 47 42
  1. I think you should remove the status as we agreed. This error message got triggered when I tried to update my profile.
Screen Shot 2019-08-13 at 14 46 20
  1. You should remove those purple characters for the error message to be easily read.
Screen Shot 2019-08-13 at 14 59 02

thanks for the feedback. I am going to work on them. However, on feedback number 3, I think It's not necessary to protect the route because you are limiting the user to get the other profiles of the people. If a person could get or read other people's article also he should be able to get their profiles. And on feedback 4, because It's not me who worked on authentications, I did not want to touch into other people's file. So We agreed with the TTL to make the chore of cleaning up the codebase

About the feedback 3, The user will be able to retrieve other user's profiles as long as they have logged in. Therefore, Protecting the route will not block the user from retrieving others' profiles.
About the feedback 4, You are allowed to do that because I also did it when I removed the status messages from Malaba's user controller. I think it is okay.

@placideirandora I talked to TTL about this. and we agreed to make a chore of doing that

Ok. It is because when I received the feedback about email confirmation link, I asked if I could modify other's methods for me to be able to implement the feedback and he told that I could do that. For me, I removed them already. So, That chore will be only for removing that one that I have mentioned for you to remove. A chore to remove one status message.

@raymond42 raymond42 temporarily deployed to codinggeeks-ah-backnd-st-pr-18 August 14, 2019 15:35 Inactive
@raymond42 raymond42 changed the title 167484590: create user profiles upon successful registration #167484590: create user profiles upon successful registration Aug 14, 2019
@raymond42 raymond42 temporarily deployed to codinggeeks-ah-backnd-st-pr-18 August 14, 2019 20:23 Inactive
@mkiterian mkiterian merged commit 25b07ca into development Aug 15, 2019
@mkiterian mkiterian deleted the ft-user-profile-#167484590 branch August 15, 2019 12:29
@placideirandora placideirandora added finished and removed Need Reviews Feedback to PR raised labels Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants