From f2ae0e6befee4ec20a9ef40418a5628586b8ca71 Mon Sep 17 00:00:00 2001 From: Oscar Eriksson Date: Mon, 11 Nov 2024 12:15:23 +0100 Subject: [PATCH] Use extended Auth API for managed accounts --- internal/pkg/services/auth/models.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/internal/pkg/services/auth/models.go b/internal/pkg/services/auth/models.go index 6e71b0b..5fc7be4 100644 --- a/internal/pkg/services/auth/models.go +++ b/internal/pkg/services/auth/models.go @@ -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"` @@ -15,6 +18,7 @@ type AuthSuperGroup struct { } `json:"post"` User AuthUser `json:"user"` } `json:"members"` + UseManagedAccount bool `json:"useManagedAccount"` } type AuthUser struct { @@ -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", }, } } @@ -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 }