Reformatted files

This commit is contained in:
ITQ
2024-03-03 18:15:03 +03:00
parent 20e6e512d2
commit 12bda5d3da
3 changed files with 8 additions and 3 deletions
+3 -1
View File
@@ -15,7 +15,9 @@ class JWTAuthentication(BaseAuthentication):
return "Provide a valid token in the 'Authorization' header" return "Provide a valid token in the 'Authorization' header"
def authenticate(self, request): def authenticate(self, request):
if not IsAuthenticated in getattr(request.resolver_match.func.cls, "permission_classes", []): if IsAuthenticated not in getattr(
request.resolver_match.func.cls, "permission_classes", []
):
return None return None
token = request.headers.get("Authorization", "").split("Bearer ")[-1] token = request.headers.get("Authorization", "").split("Bearer ")[-1]
+1 -1
View File
@@ -42,5 +42,5 @@ urlpatterns = [
"me/updatePassword", "me/updatePassword",
api.users.views.PasswordChangeApiView.as_view(), api.users.views.PasswordChangeApiView.as_view(),
name="password-change", name="password-change",
) ),
] ]
+4 -1
View File
@@ -210,7 +210,10 @@ class PasswordChangeApiView(APIView):
old_password = serializer.validated_data.get("oldPassword") old_password = serializer.validated_data.get("oldPassword")
new_password = serializer.validated_data.get("newPassword") new_password = serializer.validated_data.get("newPassword")
if bcrypt.checkpw(old_password.encode("utf-8"), request.user.password.encode("utf-8")): if bcrypt.checkpw(
old_password.encode("utf-8"),
request.user.password.encode("utf-8"),
):
password_hash = bcrypt.hashpw( password_hash = bcrypt.hashpw(
new_password.encode("utf-8"), bcrypt.gensalt() new_password.encode("utf-8"), bcrypt.gensalt()
).decode("utf-8") ).decode("utf-8")