From cb5a78f0dd87a1be72787028e594443e8941bb34 Mon Sep 17 00:00:00 2001 From: Benedikt Kulmann Date: Mon, 19 Oct 2020 12:29:10 +0200 Subject: [PATCH] Allow email on auth queries --- accounts/pkg/service/v0/accounts.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/accounts/pkg/service/v0/accounts.go b/accounts/pkg/service/v0/accounts.go index af4a9c068c..bca89e9765 100644 --- a/accounts/pkg/service/v0/accounts.go +++ b/accounts/pkg/service/v0/accounts.go @@ -122,9 +122,15 @@ func (s Service) ListAccounts(ctx context.Context, in *proto.ListAccountsRequest } ids, err := s.index.FindBy(&proto.Account{}, "OnPremisesSamAccountName", match[1]) - if err != nil || len(ids) != 1 { + if err != nil || len(ids) > 1 { return merrors.Unauthorized(s.id, "account not found or invalid credentials") } + if len(ids) == 0 { + ids, err = s.index.FindBy(&proto.Account{}, "Mail", match[1]) + if err != nil || len(ids) != 1 { + return merrors.Unauthorized(s.id, "account not found or invalid credentials") + } + } a := &proto.Account{} err = s.repo.LoadAccount(ctx, ids[0], a)