mirror of
https://github.com/juanfont/headscale.git
synced 2026-04-25 10:08:41 +02:00
state: update policy manager when deleting users
Make DeleteUser call updatePolicyManagerUsers() to refresh the policy manager's cached user list after user deletion. This ensures consistency with CreateUser, UpdateUser, and RenameUser which all update the policy manager. Previously, DeleteUser only removed the user from the database without updating the policy manager. This could leave stale user references in the cached user list, potentially causing issues when policy is re-evaluated. The gRPC handler now uses the change returned from DeleteUser instead of manually constructing change.UserRemoved(). Fixes #2967
This commit is contained in:
@@ -28,7 +28,6 @@ import (
|
||||
v1 "github.com/juanfont/headscale/gen/go/headscale/v1"
|
||||
"github.com/juanfont/headscale/hscontrol/state"
|
||||
"github.com/juanfont/headscale/hscontrol/types"
|
||||
"github.com/juanfont/headscale/hscontrol/types/change"
|
||||
"github.com/juanfont/headscale/hscontrol/util"
|
||||
)
|
||||
|
||||
@@ -99,13 +98,13 @@ func (api headscaleV1APIServer) DeleteUser(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = api.h.state.DeleteUser(types.UserID(user.ID))
|
||||
policyChanged, err := api.h.state.DeleteUser(types.UserID(user.ID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// User deletion may affect policy, trigger a full policy re-evaluation.
|
||||
api.h.Change(change.UserRemoved())
|
||||
// Use the change returned from DeleteUser which includes proper policy updates
|
||||
api.h.Change(policyChanged)
|
||||
|
||||
return &v1.DeleteUserResponse{}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user