set admin field for backward compatbility

This commit is contained in:
abhishek9686 2024-07-07 10:49:01 +05:30
parent 4996122090
commit 34bcff2b1d
5 changed files with 16 additions and 0 deletions

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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