mirror of
https://github.com/juanfont/headscale.git
synced 2026-07-08 00:50:20 +09:00
fix: scope DestroyUser to only delete target user's pre-auth keys
DestroyUser called ListPreAuthKeys(tx) which returns ALL keys in the
database, then deleted every one of them. This caused deleting any
single user to wipe all pre-auth keys system-wide.
Fix: query only keys belonging to the user being deleted using
tx.Where("user_id = ?", uid).Find(&keys).
Fixes: https://github.com/juanfont/headscale/issues/3154
This commit is contained in:
@@ -58,8 +58,8 @@ func DestroyUser(tx *gorm.DB, uid types.UserID) error {
|
||||
return ErrUserStillHasNodes
|
||||
}
|
||||
|
||||
keys, err := ListPreAuthKeys(tx)
|
||||
if err != nil {
|
||||
var keys []types.PreAuthKey
|
||||
if err := tx.Where("user_id = ?", uid).Find(&keys).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
for _, key := range keys {
|
||||
|
||||
Reference in New Issue
Block a user