1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-06 18:43:43 +00:00

revert old bearer code. use bearer scheme again

This commit is contained in:
Kyle Spearrin
2017-08-10 10:16:58 -04:00
parent f231565163
commit 0eb68ec461
6 changed files with 3 additions and 116 deletions

View File

@@ -150,8 +150,7 @@ namespace Bit.App.Services
get
{
return _cryptoService.Key != null &&
(!string.IsNullOrWhiteSpace(_tokenService.Token) ||
!string.IsNullOrWhiteSpace(_tokenService.AuthBearer)) &&
!string.IsNullOrWhiteSpace(_tokenService.Token) &&
!string.IsNullOrWhiteSpace(UserId);
}
}
@@ -199,7 +198,6 @@ namespace Bit.App.Services
{
_tokenService.Token = null;
_tokenService.RefreshToken = null;
_tokenService.AuthBearer = null;
UserId = null;
Email = null;
_cryptoService.ClearKeys();

View File

@@ -11,14 +11,12 @@ namespace Bit.App.Services
private const string TokenKey = "accessToken";
private const string RefreshTokenKey = "refreshToken";
private const string TwoFactorTokenKeyFormat = "twoFactorToken_{0}";
private const string AuthBearerKey = "token";
private readonly ISecureStorageService _secureStorage;
private string _token;
private dynamic _decodedToken;
private string _refreshToken;
private string _authBearer;
public TokenService(ISecureStorageService secureStorage)
{
@@ -54,7 +52,6 @@ namespace Bit.App.Services
{
_secureStorage.Delete(TokenKey);
RefreshToken = null;
AuthBearer = null;
}
_decodedToken = null;
@@ -132,40 +129,6 @@ namespace Bit.App.Services
}
}
public string AuthBearer
{
get
{
if(_authBearer != null)
{
return _authBearer;
}
var tokenBytes = _secureStorage.Retrieve(AuthBearerKey);
if(tokenBytes == null)
{
return null;
}
_authBearer = Encoding.UTF8.GetString(tokenBytes, 0, tokenBytes.Length);
return _authBearer;
}
set
{
if(value != null)
{
var tokenBytes = Encoding.UTF8.GetBytes(value);
_secureStorage.Store(AuthBearerKey, tokenBytes);
}
else
{
_secureStorage.Delete(AuthBearerKey);
}
_authBearer = value;
}
}
public string GetTwoFactorToken(string email)
{
var emailEncoded = Convert.ToBase64String(Encoding.UTF8.GetBytes(email));