Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1335 | Admin can force mark verified any user
Browse files Browse the repository at this point in the history
  • Loading branch information
snyaggarwal committed Jul 14, 2022
1 parent bdc6af3 commit fa8a898
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ def email_verification_url(self):
def reset_password_url(self):
return f"{web_url()}/#/accounts/{self.username}/password/reset/{self.verification_token}/"

def mark_verified(self, token):
def mark_verified(self, token, force=False):
if self.verified:
return True

if token == self.verification_token:
if token == self.verification_token or force:
self.verified = True
self.verification_token = None
self.deactivated_at = None
Expand Down
2 changes: 1 addition & 1 deletion core/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def get(self, request, *args, **kwargs): # pylint: disable=unused-argument
if not user:
return Response(status=status.HTTP_404_NOT_FOUND)

result = user.mark_verified(kwargs.get('verification_token'))
result = user.mark_verified(token=kwargs.get('verification_token'), force=user.is_staff)
if result:
update_last_login(None, user)
return Response({'token': user.get_token()}, status=status.HTTP_200_OK)
Expand Down

0 comments on commit fa8a898

Please sign in to comment.