Skip to content

Instantly share code, notes, and snippets.

@unicodeveloper
Created September 12, 2016 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unicodeveloper/49f638aad5a1ff8d6cc9abc1b722f515 to your computer and use it in GitHub Desktop.
Save unicodeveloper/49f638aad5a1ff8d6cc9abc1b722f515 to your computer and use it in GitHub Desktop.
Cloudinary Blog Post - Part 1
1. The welcome function simply returns a json response that says "Welcome to Yourtube Api"
2. The registerUser function, with the aid of the User model checks if a user already exists with that email coming from the user input. If no user exists with that email, It gets the avatar of the user, saves the user details and creates a secure token else it returns an appropriate message. token.createJWT does the work of creating the token. The createJWT function can be found in the config/token file.
3. The getLoggedInUserDetail function queries the user collection and returns the user detail.
4. The updateLoggedInUserDetail function updates the user details in the user collection.
5. The authenticate function verifies if the email and password matches before returning a valid token.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment