Skip to content

Commit

Permalink
log rejecting users
Browse files Browse the repository at this point in the history
prints some information in the server log since we don't record such events publicly.
this also helps in case of a rejection by mistake, since we can contact the rejected user via email from the log.
  • Loading branch information
peregrineshahin authored and ppigazzini committed May 12, 2024
1 parent 8c7ec81 commit b204b37
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
16 changes: 8 additions & 8 deletions server/fishtest/templates/user.mak
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,22 @@
<label class="mb-2 h5">User Approval:</label>
<div class="w-100 d-flex justify-content-between">
<button
id="accept_user"
id="reject_user"
name="pending"
value="0"
value="1"
type="submit"
class="btn btn-success"
class="btn btn-danger"
style="width: 48%;"
>Accept</button>
>Reject</button>

<button
id="reject_user"
id="accept_user"
name="pending"
value="1"
value="0"
type="submit"
class="btn btn-danger"
class="btn btn-success"
style="width: 48%;"
>Reject</button>
>Accept</button>
</div>
</div>
% else:
Expand Down
8 changes: 7 additions & 1 deletion server/fishtest/userdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,18 @@ def save_user(self, user):
self.last_blocked_time = 0
self.clear_cache()

def remove_user(self, user):
def remove_user(self, user, rejector):

result = self.users.delete_one({"_id": user["_id"]})
if result.deleted_count > 0:
# User successfully deleted
self.last_pending_time = 0
self.clear_cache()
# logs rejected users to the server
print(
f"user: {user['username']} with email: {user['email']} was rejected by: {rejector}",
flush=True,
)
return True
else:
# User not found
Expand Down
2 changes: 1 addition & 1 deletion server/fishtest/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def user(request):
message="accepted",
)
else:
request.userdb.remove_user(user_data)
request.userdb.remove_user(user_data, userid)
return home(request)
userc = request.userdb.user_cache.find_one({"username": user_name})
hours = int(userc["cpu_hours"]) if userc is not None else 0
Expand Down

0 comments on commit b204b37

Please sign in to comment.