From d390942581a76ec0090fdbdc7f2f690cf773b920 Mon Sep 17 00:00:00 2001 From: Doug Lauder Date: Wed, 22 Apr 2020 09:09:13 -0400 Subject: [PATCH] MM-24217 ensure updating Mfa secret and status invalidates cache (#14334) --- app/user.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/user.go b/app/user.go index c84df4f4c6..60871dbe00 100644 --- a/app/user.go +++ b/app/user.go @@ -625,6 +625,9 @@ func (a *App) GenerateMfaSecret(userId string) (*model.MfaSecret, *model.AppErro return nil, err } + // Make sure the old secret is not cached on any cluster nodes. + a.InvalidateCacheForUser(user.Id) + mfaSecret := &model.MfaSecret{Secret: secret, QRCode: b64.StdEncoding.EncodeToString(img)} return mfaSecret, nil } @@ -644,6 +647,9 @@ func (a *App) ActivateMfa(userId, token string) *model.AppError { return err } + // Make sure old MFA status is not cached locally or in cluster nodes. + a.InvalidateCacheForUser(userId) + return nil } @@ -653,6 +659,9 @@ func (a *App) DeactivateMfa(userId string) *model.AppError { return err } + // Make sure old MFA status is not cached locally or in cluster nodes. + a.InvalidateCacheForUser(userId) + return nil }