Fakultas Ilmu Komputer UI

Commit e0f58902 authored by Jonathan Christopher Jakub's avatar Jonathan Christopher Jakub
Browse files

[GREEN] Check is_verified in permission

parent 182673a3
Pipeline #39771 passed with stages
in 13 minutes and 4 seconds
......@@ -28,3 +28,4 @@ class AccountFactory(factory.DjangoModelFactory):
phone_number = faker.phone_number()
area = faker.city()
is_active = True
is_verified = True
......@@ -88,9 +88,9 @@ class AccountViewTest(APITestCase):
"email": self.officer.email,
"phone_number": self.officer.phone_number,
"area": self.officer.area,
"is_admin": False,
"is_verified": False,
"is_active": True,
"is_admin": self.officer.is_admin,
"is_verified": self.officer.is_verified,
"is_active": self.officer.is_active,
}
self.assertJSONEqual(json.dumps(response.data), data)
......@@ -237,9 +237,9 @@ class AccountViewTest(APITestCase):
"email": self.admin.email,
"phone_number": self.admin.phone_number,
"area": self.admin.area,
"is_admin": True,
"is_verified": False,
"is_active": True,
"is_admin": self.admin.is_admin,
"is_verified": self.admin.is_verified,
"is_active": self.admin.is_active,
}
self.assertEqual(response.status_code, status.HTTP_200_OK)
......
......@@ -6,7 +6,11 @@ from django.core.exceptions import ObjectDoesNotExist
class IsAuthenticated(BasePermission):
def has_permission(self, request, view):
user = request.user
return user.is_authenticated and user.account.is_active
return (
user.is_authenticated
and user.account.is_active
and user.account.is_verified
)
class CreateOnly(BasePermission):
......
......@@ -82,9 +82,9 @@ class ActivityLogViewTest(APITestCase):
"email": self.account.email,
"phone_number": self.account.phone_number,
"area": self.account.area,
"is_admin": False,
"is_verified": False,
"is_active": True,
"is_admin": self.account.is_admin,
"is_verified": self.account.is_verified,
"is_active": self.account.is_active,
},
},
],
......
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