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

[FEAT]: JWT Authentication on backend #9

Open
adityanandanx opened this issue Aug 12, 2024 · 5 comments
Open

[FEAT]: JWT Authentication on backend #9

adityanandanx opened this issue Aug 12, 2024 · 5 comments
Assignees
Labels
backend Backend knowledge required enhancement New feature or request

Comments

@adityanandanx
Copy link
Owner

adityanandanx commented Aug 12, 2024

Requirements

Create a new django app (not project, see this) called auth which has these endpoints -

  • /auth/register - User can create an account
    • method: POST
    • body: email, password, confirm_password, full_name
    • response: status, message, access_token, refresh_token
  • /auth/login - User can login to their account
    • method: POST
    • body: email, password
    • response: status, message, access_token, refresh_token
  • /auth/logout - User can logout of their account
    • method: POST
    • body: nothing
    • header: Authorization: Bearer <access_token>
    • response: status, message
  • /auth/refresh - User can refresh their access_token
    • method: POST
    • body: refresh_token
    • response: status, message, access_token

Resources

@adityanandanx adityanandanx added enhancement New feature or request backend Backend knowledge required labels Aug 12, 2024
@SharonIV0x86
Copy link

I would like to work on this issue. Kindly assign this to me.

@SharonIV0x86
Copy link

I am currently facing issue while making the migrations after adding a dummy model, it is because of the conflicting the name of the app which is auth with the default django package which is django.contrib.auth under the INSTALLED_APPS in the settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    .....
    "auth"
]

The solution was to change the name of the app from auth to authentication. I hope this modification in the application name is fine.
@adityanandanx

@adityanandanx
Copy link
Owner Author

yeah it's fine @SharonIV0x86

@SharonIV0x86
Copy link

I currently have this User model created with the following fields and the serializer. I am requesting some reviews on it.

class User(models.Model):
    age = models.IntegerField()
    firstName = models.CharField(max_length=30)
    lastName = models.CharField(max_length=30)
    email = models.CharField(max_length=40, unique=True)
    password = models.CharField(max_length=40)
    role = models.CharField(max_length=12)

And the UserSerializer that serializes all the fields. I have mixed opinions on serializing all the fields and return them in the response.

class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = "__all__" #serializing all fields
        #fields = ['password', 'email'] #serializing some fields

Suggest any addition or changes to them.
@adityanandanx

@adityanandanx
Copy link
Owner Author

You don't have to create a new User model. Django already handles those internally.
See this
@SharonIV0x86

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Backend knowledge required enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants