Reformatted files
This commit is contained in:
@@ -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]
|
||||||
|
|||||||
@@ -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",
|
||||||
)
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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")
|
||||||
|
|||||||
Reference in New Issue
Block a user