Fakultas Ilmu Komputer UI

Commit 0d8307ff authored by Jonathan Christopher Jakub's avatar Jonathan Christopher Jakub
Browse files

[GREEN] Validate password upon register and lowercasing username

parent 7fefe2e1
Pipeline #40338 passed with stages
in 3 minutes and 8 seconds
from django.contrib.auth import password_validation
from rest_framework import serializers
from apps.accounts.models import Account
......@@ -41,3 +43,7 @@ class AccountRegisterSerializer(serializers.ModelSerializer):
"area",
"is_admin",
]
def validate_password(self, value):
password_validation.validate_password(value)
return value
......@@ -51,7 +51,7 @@ class AccountViewSet(viewsets.ViewSet):
serializer = AccountRegisterSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
username = serializer.validated_data.pop("username")
username = serializer.validated_data.pop("username").lower()
password = serializer.validated_data.pop("password")
user = User.objects.create_user(username=username, password=password)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment