mirror of
https://github.com/gravitl/netmaker.git
synced 2025-10-05 03:14:28 +08:00
delete netID if net roles are empty
This commit is contained in:
parent
f7453f8cb6
commit
9adb36b82c
2 changed files with 11 additions and 4 deletions
|
@ -22,10 +22,7 @@ import (
|
|||
)
|
||||
|
||||
func UserHandlers(r *mux.Router) {
|
||||
r.HandleFunc("/api/users/{username}/remote_access_gw/{remote_access_gateway_id}", logic.SecurityCheck(true, http.HandlerFunc(attachUserToRemoteAccessGw))).Methods(http.MethodPost)
|
||||
r.HandleFunc("/api/users/{username}/remote_access_gw/{remote_access_gateway_id}", logic.SecurityCheck(true, http.HandlerFunc(removeUserFromRemoteAccessGW))).Methods(http.MethodDelete)
|
||||
r.HandleFunc("/api/users/{username}/remote_access_gw", logic.SecurityCheck(false, logic.ContinueIfUserMatch(http.HandlerFunc(getUserRemoteAccessGwsV1)))).Methods(http.MethodGet)
|
||||
r.HandleFunc("/api/users/ingress/{ingress_id}", logic.SecurityCheck(true, http.HandlerFunc(ingressGatewayUsers))).Methods(http.MethodGet)
|
||||
|
||||
r.HandleFunc("/api/oauth/login", proAuth.HandleAuthLogin).Methods(http.MethodGet)
|
||||
r.HandleFunc("/api/oauth/callback", proAuth.HandleAuthCallback).Methods(http.MethodGet)
|
||||
r.HandleFunc("/api/oauth/headless", proAuth.HandleHeadlessSSO)
|
||||
|
@ -58,6 +55,11 @@ func UserHandlers(r *mux.Router) {
|
|||
r.HandleFunc("/api/users_pending/user/{username}", logic.SecurityCheck(true, http.HandlerFunc(deletePendingUser))).Methods(http.MethodDelete)
|
||||
r.HandleFunc("/api/users_pending/user/{username}", logic.SecurityCheck(true, http.HandlerFunc(approvePendingUser))).Methods(http.MethodPost)
|
||||
|
||||
r.HandleFunc("/api/users/{username}/remote_access_gw/{remote_access_gateway_id}", logic.SecurityCheck(true, http.HandlerFunc(attachUserToRemoteAccessGw))).Methods(http.MethodPost)
|
||||
r.HandleFunc("/api/users/{username}/remote_access_gw/{remote_access_gateway_id}", logic.SecurityCheck(true, http.HandlerFunc(removeUserFromRemoteAccessGW))).Methods(http.MethodDelete)
|
||||
r.HandleFunc("/api/users/{username}/remote_access_gw", logic.SecurityCheck(false, logic.ContinueIfUserMatch(http.HandlerFunc(getUserRemoteAccessGwsV1)))).Methods(http.MethodGet)
|
||||
r.HandleFunc("/api/users/ingress/{ingress_id}", logic.SecurityCheck(true, http.HandlerFunc(ingressGatewayUsers))).Methods(http.MethodGet)
|
||||
|
||||
}
|
||||
|
||||
// swagger:route POST /api/v1/users/invite-signup user userInviteSignUp
|
||||
|
|
|
@ -679,11 +679,16 @@ func IsGroupsValid(groups map[models.UserGroupID]struct{}) error {
|
|||
|
||||
func IsNetworkRolesValid(networkRoles map[models.NetworkID]map[models.UserRoleID]struct{}) error {
|
||||
for netID, netRoles := range networkRoles {
|
||||
|
||||
if netID != models.AllNetworks {
|
||||
_, err := logic.GetNetwork(netID.String())
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to fetch network %s ", netID)
|
||||
}
|
||||
if len(netRoles) == 0 {
|
||||
delete(networkRoles, netID)
|
||||
continue
|
||||
}
|
||||
}
|
||||
for netRoleID := range netRoles {
|
||||
role, err := logic.GetRole(netRoleID)
|
||||
|
|
Loading…
Add table
Reference in a new issue