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
This commit is contained in:
Fabi 2020-06-26 08:31:25 +02:00 committed by GitHub
parent 785c8d9763
commit ee73dc07dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}