From 72e2475e0666203bf00575f4e3b5f07ba4be5373 Mon Sep 17 00:00:00 2001 From: Oscar Eriksson Date: Wed, 13 Nov 2024 13:48:58 +0100 Subject: [PATCH] Do ToLower on google emails --- internal/pkg/services/admin/service_groups.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/pkg/services/admin/service_groups.go b/internal/pkg/services/admin/service_groups.go index 051ed11..fa29de0 100644 --- a/internal/pkg/services/admin/service_groups.go +++ b/internal/pkg/services/admin/service_groups.go @@ -2,6 +2,7 @@ package admin import ( "fmt" + "strings" "time" "github.com/cthit/goldapps/internal/pkg/model" @@ -28,7 +29,7 @@ func (s googleService) UpdateGroup(groupUpdate model.GroupUpdate) error { } } if !exists { - _, err := s.adminService.Members.Insert(groupUpdate.Before.Email, &admin.Member{Email: member}).Do() + _, err := s.adminService.Members.Insert(groupUpdate.Before.Email, &admin.Member{Email: strings.ToLower(member)}).Do() if err != nil { fmt.Printf("Failed to add menber %s\n", member) return err @@ -93,7 +94,7 @@ func (s googleService) UpdateGroup(groupUpdate model.GroupUpdate) error { func (s googleService) AddGroup(group model.Group) error { newGroup := admin.Group{ - Email: group.Email, + Email: strings.ToLower(group.Email), } _, err := s.adminService.Groups.Insert(&newGroup).Do() @@ -105,7 +106,7 @@ func (s googleService) AddGroup(group model.Group) error { // Add members for _, member := range group.Members { - _, err := s.adminService.Members.Insert(group.Email, &admin.Member{Email: member}).Do() + _, err := s.adminService.Members.Insert(strings.ToLower(group.Email), &admin.Member{Email: strings.ToLower(member)}).Do() if err != nil { return err } @@ -113,7 +114,7 @@ func (s googleService) AddGroup(group model.Group) error { // Add Aliases for _, alias := range group.Aliases { - _, err := s.adminService.Groups.Aliases.Insert(group.Email, &admin.Alias{Alias: alias}).Do() + _, err := s.adminService.Groups.Aliases.Insert(strings.ToLower(group.Email), &admin.Alias{Alias: alias}).Do() if err != nil { return err } @@ -197,7 +198,7 @@ func (s googleService) getGoogleGroupMembers(email string) ([]string, error) { result := make([]string, len(members.Members)) for i, member := range members.Members { - result[i] = member.Email + result[i] = strings.ToLower(member.Email) } return result, nil