Skip to content

Commit

Permalink
Use extended Auth API for managed accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscariremma committed Nov 11, 2024
1 parent e84e417 commit f2ae0e6
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions internal/pkg/services/auth/models.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package auth

import "github.com/cthit/goldapps/internal/pkg/model"
import (
"github.com/cthit/goldapps/internal/pkg/model"
"strings"
)

type AuthSuperGroup struct {
Name string `json:"name"`
Expand All @@ -15,6 +18,7 @@ type AuthSuperGroup struct {
} `json:"post"`
User AuthUser `json:"user"`
} `json:"members"`
UseManagedAccount bool `json:"useManagedAccount"`
}

type AuthUser struct {
Expand All @@ -36,7 +40,7 @@ func (user AuthUser) ToUser() model.Users {
FirstName: user.FirstName,
SecondName: user.LastName,
Nick: user.Nick,
Mail: user.Email,
Mail: strings.ToLower(user.Cid) + "@chalmers.it",
},
}
}
Expand All @@ -51,12 +55,18 @@ func (users AuthUsers) ToUsers() model.Users {

func (superGroup AuthSuperGroup) ToGroup() model.Group {
group := model.Group{
Email: superGroup.Name + "@chalmers.it",
Email: strings.ToLower(superGroup.Name) + "@chalmers.it",
Type: superGroup.Type,
Aliases: []string{},
}
for _, member := range superGroup.Members {
group.Members = append(group.Members, member.User.Email)
var memberEmail string
if superGroup.UseManagedAccount {
memberEmail = member.User.Cid + "@chalmers.it"
} else {
memberEmail = member.User.Email
}
group.Members = append(group.Members, strings.ToLower(memberEmail))
}
return group
}
Expand Down

0 comments on commit f2ae0e6

Please sign in to comment.