Skip to content

Introduction to backend - Authentication #81

Description

@angeldzzz23

Goal: by the end you should implement understand how:
account creation, verifying email, editing a user, deleting a user and refreshing a user works.

Reasoning: most of the other endpoints of this project refer to the models and views created in project.

Beginning

1 Download postman

  • get access to the our postman project

2 generating fake user data /api/auth/generateData

this will create skills, genres and other features that are needed to edit a user.

  • run the post endpoint using postman

Screenshot 2023-03-10 at 10 47 22 AM

Jumping into registering a user

Using the /api/auth/register endpoint

  • create a user for yourself.

Screenshot 2023-03-10 at 10 49 51 AM

Logging in a user

Post using /api/auth/login

  • log in your created user
  • the purpose of this is to generate the two types of tokens: an access token and a refresh token.
  • it also generes two cookies with the same information/
  • the access token is used to authenticate the user. It expires after 18 hours
  • the refresh token is used to create another set of tokens after the access token expires.
  • most of the time, the access token is passed in the header of the request.

Editing a user

Patch 8000/api/auth/user

  • try editing a user
  • the purpose of this endpoint is to edit certain features of a user.

Getting a user

get /api/auth/user

  • try returning the information of a user.
  • returns all of the information of the user

Refreshing a token

post /api/auth/refreshWC

  • refreshes the user tokens
  • notice how this returns the information.

Attributes of a a user.

{
    "success": true,
    "user": {
        "first_name": "1234",
        "last_name": "fffan",
        "gender_name": "Male",
        "DOB": "1999-06-22",
        "about_me": "I created myspace!!!",
        "skills": [
            {
                "skill_id": 4,
                "skill_name": "Camera"
            },
            {
                "skill_id": 1,
                "skill_name": "Baterista"
            },
            {
                "skill_id": 3,
                "skill_name": "Writer"
            }
        ],
        "genres": [
            {
                "genre_id": 1,
                "genre_name": "Regional"
            },
            {
                "genre_id": 3,
                "genre_name": "Rap"
            },
            {
                "genre_id": 2,
                "genre_name": "pop"
            }
        ],
        "artists": [
            {
                "user_artist_id": 31,
                "artist": "kakakmakakkaka"
            },
            {
                "user_artist_id": 32,
                "artist": "akkakakkaka"
            },
            {
                "user_artist_id": 33,
                "artist": "jnnbn23j32ajaj"
            }
        ],
        "youtube_vids": [
            {
                "youtube_id": 17,
                "video_id": "abc"
            },
            {
                "youtube_id": 18,
                "video_id": "ajkajkajajjaja"
            }
        ],
        "vimeo_vids": [
            {
                "vimeo_id": 13,
                "video_id": "1234355"
            },
            {
                "vimeo_id": 14,
                "video_id": "3456"
            }
        ],
        "nationalities": [
            {
                "nationality_id": 1,
                "nationality_name": "mexico"
            },
            {
                "nationality_id": 2,
                "nationality_name": "Argentina"
            }
        ]
    }
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions