fix user validation in factory (#3031)
#### Type of change - [x] 🐛 Bugfix #### Test Plan - [x] 💪 Manual - [x] 💚 E2E
This commit is contained in:
parent
ec30c9ccce
commit
c949c333e4
@ -88,8 +88,7 @@ func generateAndRestoreItems(
|
||||
service,
|
||||
tenantID, userID,
|
||||
dest,
|
||||
collections,
|
||||
)
|
||||
collections)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -121,21 +120,18 @@ func getGCAndVerifyUser(ctx context.Context, userID string) (*connector.GraphCon
|
||||
return nil, account.Account{}, clues.Wrap(err, "finding m365 account details")
|
||||
}
|
||||
|
||||
// build a graph connector
|
||||
// TODO: log/print recoverable errors
|
||||
errs := fault.New(false)
|
||||
normUsers := map[string]struct{}{}
|
||||
|
||||
ins, err := m365.UsersMap(ctx, acct, errs)
|
||||
if err != nil {
|
||||
return nil, account.Account{}, clues.Wrap(err, "getting tenant users")
|
||||
}
|
||||
|
||||
for _, k := range ins.IDs() {
|
||||
normUsers[strings.ToLower(k)] = struct{}{}
|
||||
}
|
||||
_, idOK := ins.NameOf(strings.ToLower(userID))
|
||||
_, nameOK := ins.IDOf(strings.ToLower(userID))
|
||||
|
||||
if _, ok := normUsers[strings.ToLower(User)]; !ok {
|
||||
if !idOK && !nameOK {
|
||||
return nil, account.Account{}, clues.New("user not found within tenant")
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package m365
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/alcionai/clues"
|
||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||
@ -75,8 +76,9 @@ func UsersMap(
|
||||
)
|
||||
|
||||
for _, u := range users {
|
||||
idToName[u.ID] = u.PrincipalName
|
||||
nameToID[u.PrincipalName] = u.ID
|
||||
id, name := strings.ToLower(u.ID), strings.ToLower(u.PrincipalName)
|
||||
idToName[id] = name
|
||||
nameToID[name] = id
|
||||
}
|
||||
|
||||
ins := common.IDsNames{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user