Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects

Generate random password and change password

Merged Rony Agus Vian requested to merge vian/change-password into pbi-11-lupa-password
1 file
+ 3
3
Compare changes
  • Side-by-side
  • Inline
+ 3
3
@@ -11,7 +11,7 @@ from rest_framework.response import Response
from django.core.exceptions import ValidationError
from django.db import transaction
from random import SystemRandom
from string import ascii_uppercase, digits
from string import ascii_uppercase, ascii_lowercase, digits
from apps.accounts.filters import (
ACCOUNT_FILTERSET_FIELDS,
@@ -155,8 +155,8 @@ class AccountViewSet(viewsets.ModelViewSet):
user = request.user
username = user.username
new_password = ''.join(SystemRandom().choice(ascii_uppercase + digits)
for length in range(10))
new_password = ''.join(SystemRandom().choice(ascii_lowercase + ascii_uppercase + digits)
for _ in range(10))
if User.objects.filter(username=username).exists():
user = User.objects.get(username=username)
Loading