From ae35bd2047fb2ffdc1ea77cea4e689ba10ca1e8f Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 27 Jun 2017 16:51:16 -0400 Subject: [PATCH] encode email for token service key --- src/App/Services/TokenService.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/App/Services/TokenService.cs b/src/App/Services/TokenService.cs index 7e76346b6..ed966f6b1 100644 --- a/src/App/Services/TokenService.cs +++ b/src/App/Services/TokenService.cs @@ -168,7 +168,8 @@ namespace Bit.App.Services public string GetTwoFactorToken(string email) { - var tokenBytes = _secureStorage.Retrieve(string.Format(TwoFactorTokenKeyFormat, email)); + var emailEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(email)); + var tokenBytes = _secureStorage.Retrieve(string.Format(TwoFactorTokenKeyFormat, emailEncoded)); if(tokenBytes == null) { return null; @@ -179,7 +180,8 @@ namespace Bit.App.Services public void SetTwoFactorToken(string email, string token) { - var key = string.Format(TwoFactorTokenKeyFormat, email); + var emailEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(email)); + var key = string.Format(TwoFactorTokenKeyFormat, emailEncoded); if(token != null) { var tokenBytes = Encoding.UTF8.GetBytes(token);