mirror of
https://github.com/gravitl/netmaker.git
synced 2025-12-11 06:47:21 +08:00
set admin field for backward compatbility
This commit is contained in:
parent
4996122090
commit
34bcff2b1d
5 changed files with 16 additions and 0 deletions
|
|
@ -1112,6 +1112,7 @@ func userInviteSignUp(w http.ResponseWriter, r *http.Request) {
|
|||
logic.ReturnErrorResponse(w, r, logic.FormatError(errors.New("password cannot be empty"), "badrequest"))
|
||||
return
|
||||
}
|
||||
|
||||
for _, inviteGroupID := range in.Groups {
|
||||
userG, err := logic.GetUserGroup(inviteGroupID)
|
||||
if err != nil {
|
||||
|
|
@ -1121,6 +1122,9 @@ func userInviteSignUp(w http.ResponseWriter, r *http.Request) {
|
|||
user.PlatformRoleID = userG.PlatformRole
|
||||
user.UserGroups[inviteGroupID] = struct{}{}
|
||||
}
|
||||
if user.PlatformRoleID == models.AdminRole {
|
||||
user.IsAdmin = true
|
||||
}
|
||||
user.NetworkRoles = make(map[models.NetworkID]map[models.UserRole]struct{})
|
||||
user.IsSuperAdmin = false
|
||||
err = logic.CreateUser(&user)
|
||||
|
|
|
|||
|
|
@ -107,6 +107,9 @@ func handleAzureCallback(w http.ResponseWriter, r *http.Request) {
|
|||
user.PlatformRoleID = userG.PlatformRole
|
||||
user.UserGroups[inviteGroupID] = struct{}{}
|
||||
}
|
||||
if user.PlatformRoleID == models.AdminRole {
|
||||
user.IsAdmin = true
|
||||
}
|
||||
if err = logic.CreateUser(user); err != nil {
|
||||
handleSomethingWentWrong(w)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -107,6 +107,9 @@ func handleGithubCallback(w http.ResponseWriter, r *http.Request) {
|
|||
user.PlatformRoleID = userG.PlatformRole
|
||||
user.UserGroups[inviteGroupID] = struct{}{}
|
||||
}
|
||||
if user.PlatformRoleID == models.AdminRole {
|
||||
user.IsAdmin = true
|
||||
}
|
||||
if err = logic.CreateUser(user); err != nil {
|
||||
handleSomethingWentWrong(w)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -108,6 +108,9 @@ func handleGoogleCallback(w http.ResponseWriter, r *http.Request) {
|
|||
user.PlatformRoleID = userG.PlatformRole
|
||||
user.UserGroups[inviteGroupID] = struct{}{}
|
||||
}
|
||||
if user.PlatformRoleID == models.AdminRole {
|
||||
user.IsAdmin = true
|
||||
}
|
||||
if err = logic.CreateUser(user); err != nil {
|
||||
handleSomethingWentWrong(w)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -119,6 +119,9 @@ func handleOIDCCallback(w http.ResponseWriter, r *http.Request) {
|
|||
user.PlatformRoleID = userG.PlatformRole
|
||||
user.UserGroups[inviteGroupID] = struct{}{}
|
||||
}
|
||||
if user.PlatformRoleID == models.AdminRole {
|
||||
user.IsAdmin = true
|
||||
}
|
||||
if err = logic.CreateUser(user); err != nil {
|
||||
handleSomethingWentWrong(w)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue