mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-01-03 09:15:41 -05:00
Auto-logout when user edits their own username
Co-authored-by: KingIronMan2011 <176780813+KingIronMan2011@users.noreply.github.com>
This commit is contained in:
parent
0013aa428d
commit
c0a4ff3c50
2 changed files with 12 additions and 0 deletions
|
|
@ -85,6 +85,10 @@ module.exports.userManagementSocketHandler = (socket, server) => {
|
|||
throw new Error("User not found");
|
||||
}
|
||||
|
||||
// Check if user is editing their own username
|
||||
const isEditingSelf = (userId === socket.userID);
|
||||
const usernameChanged = userData.username && userData.username.trim() !== user.username;
|
||||
|
||||
// Update user fields
|
||||
if (userData.username && userData.username.trim() !== user.username) {
|
||||
// Check if new username already exists
|
||||
|
|
@ -114,6 +118,7 @@ module.exports.userManagementSocketHandler = (socket, server) => {
|
|||
callback({
|
||||
ok: true,
|
||||
msg: "User updated successfully",
|
||||
requiresLogout: isEditingSelf && usernameChanged,
|
||||
});
|
||||
} catch (e) {
|
||||
log.error("user-management", e.message);
|
||||
|
|
|
|||
|
|
@ -222,6 +222,13 @@ export default {
|
|||
this.$root.toastSuccess(res.msg);
|
||||
this.closeDialog();
|
||||
this.loadUsers();
|
||||
|
||||
// If user edited their own username, logout immediately
|
||||
if (res.requiresLogout) {
|
||||
setTimeout(() => {
|
||||
this.$root.logout();
|
||||
}, 1000);
|
||||
}
|
||||
} else {
|
||||
this.$root.toastError(res.msg);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue