From ee73dc07dd6b5a06da0015d644776cadd4c71acb Mon Sep 17 00:00:00 2001 From: Fabi <38692350+fgerschwiler@users.noreply.github.com> Date: Fri, 26 Jun 2020 08:31:25 +0200 Subject: [PATCH] fix: use email as account name in otp instead of userid (#274) * fix: use email as account name in otp instead of userid * fix: use email as account name in otp instead of userid --- internal/user/repository/eventsourcing/eventstore.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/user/repository/eventsourcing/eventstore.go b/internal/user/repository/eventsourcing/eventstore.go index 8ec07c1c71..962ffc9dcb 100644 --- a/internal/user/repository/eventsourcing/eventstore.go +++ b/internal/user/repository/eventsourcing/eventstore.go @@ -936,7 +936,11 @@ func (es *UserEventstore) AddOTP(ctx context.Context, userID string) (*usr_model if existing.IsOTPReady() { return nil, caos_errs.ThrowAlreadyExists(nil, "EVENT-do9se", "Errors.User.Mfa.Otp.AlreadyReady") } - key, err := totp.Generate(totp.GenerateOpts{Issuer: es.Multifactors.OTP.Issuer, AccountName: userID}) + accountName := existing.UserName + if existing.Email != nil { + accountName = existing.EmailAddress + } + key, err := totp.Generate(totp.GenerateOpts{Issuer: es.Multifactors.OTP.Issuer, AccountName: accountName}) if err != nil { return nil, err }