Skip to content

Commit

Permalink
fix: delete user was logging out when admin calling
Browse files Browse the repository at this point in the history
  • Loading branch information
wajeht committed Oct 13, 2022
1 parent 2f6ac43 commit e6ff9ed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/apps/api/v1/users/users.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,14 @@ export async function deleteUser(req, res) {

logger.info(`UserID: ${id} has disabled their account!`);

// clear jwt token
res.cookie('token', '', {
httpOnly: true,
expires: new Date(Date.now()),
});
// if request was from currently logged in user, log them out
if (user.id === req.user.user_id) {
// clear jwt token
res.cookie('token', '', {
httpOnly: true,
expires: new Date(Date.now()),
});
}

await redis.del(`user-id-${req.user.user_id}-users`);

Expand Down
6 changes: 6 additions & 0 deletions src/apps/ui/pages/admin/AdminUsers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const loading = ref(false);
const checkAll = ref(false);
const searchInput = ref('');
const checkAllRef = ref();
const deleteAUserLoading = ref(false);
const alert = reactive({ type: '', msg: '' });
Expand Down Expand Up @@ -76,11 +78,14 @@ async function deleteUser() {
checkedUsers.value = [];
checkAll.value = false;
checkAllRef.value.checked = false;
deleteAUserLoading.value = false;
clearAndDismissDeleteAUserModal();
} catch (e) {
deleteAUserLoading.value = false;
checkAll.value = false;
checkAllRef.value.checked = false;
checkedUsers.value = [];
clearAndDismissDeleteAUserModal();
appStore.loading = false;
Expand Down Expand Up @@ -215,6 +220,7 @@ function clearAndDismissDeleteAUserModal() {
<input
@click="checkAll = !checkAll"
class="form-check-input"
ref="checkAllRef"
type="checkbox"
id="checkbox-for-title"
/>
Expand Down

0 comments on commit e6ff9ed

Please sign in to comment.