mirror of
https://github.com/bitwarden/mobile
synced 2025-12-10 05:13:31 +00:00
Changed all C# control flow block statements to include space between keyword and open paren (#800)
This commit is contained in:
@@ -40,7 +40,7 @@ namespace Bit.Core.Services
|
||||
|
||||
public async Task<string> GetTokenAsync()
|
||||
{
|
||||
if(_token != null)
|
||||
if (_token != null)
|
||||
{
|
||||
return _token;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ namespace Bit.Core.Services
|
||||
|
||||
public async Task<string> GetRefreshTokenAsync()
|
||||
{
|
||||
if(_refreshToken != null)
|
||||
if (_refreshToken != null)
|
||||
{
|
||||
return _refreshToken;
|
||||
}
|
||||
@@ -91,21 +91,21 @@ namespace Bit.Core.Services
|
||||
|
||||
public JObject DecodeToken()
|
||||
{
|
||||
if(_decodedToken != null)
|
||||
if (_decodedToken != null)
|
||||
{
|
||||
return _decodedToken;
|
||||
}
|
||||
if(_token == null)
|
||||
if (_token == null)
|
||||
{
|
||||
throw new InvalidOperationException("Token not found.");
|
||||
}
|
||||
var parts = _token.Split('.');
|
||||
if(parts.Length != 3)
|
||||
if (parts.Length != 3)
|
||||
{
|
||||
throw new InvalidOperationException("JWT must have 3 parts.");
|
||||
}
|
||||
var decodedBytes = Base64UrlDecode(parts[1]);
|
||||
if(decodedBytes == null || decodedBytes.Length < 1)
|
||||
if (decodedBytes == null || decodedBytes.Length < 1)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot decode the token.");
|
||||
}
|
||||
@@ -116,7 +116,7 @@ namespace Bit.Core.Services
|
||||
public DateTime? GetTokenExpirationDate()
|
||||
{
|
||||
var decoded = DecodeToken();
|
||||
if(decoded?["exp"] == null)
|
||||
if (decoded?["exp"] == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -126,7 +126,7 @@ namespace Bit.Core.Services
|
||||
public int TokenSecondsRemaining()
|
||||
{
|
||||
var d = GetTokenExpirationDate();
|
||||
if(d == null)
|
||||
if (d == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ namespace Bit.Core.Services
|
||||
public string GetUserId()
|
||||
{
|
||||
var decoded = DecodeToken();
|
||||
if(decoded?["sub"] == null)
|
||||
if (decoded?["sub"] == null)
|
||||
{
|
||||
throw new Exception("No user id found.");
|
||||
}
|
||||
@@ -153,7 +153,7 @@ namespace Bit.Core.Services
|
||||
public string GetEmail()
|
||||
{
|
||||
var decoded = DecodeToken();
|
||||
if(decoded?["email"] == null)
|
||||
if (decoded?["email"] == null)
|
||||
{
|
||||
throw new Exception("No email found.");
|
||||
}
|
||||
@@ -163,7 +163,7 @@ namespace Bit.Core.Services
|
||||
public bool GetEmailVerified()
|
||||
{
|
||||
var decoded = DecodeToken();
|
||||
if(decoded?["email_verified"] == null)
|
||||
if (decoded?["email_verified"] == null)
|
||||
{
|
||||
throw new Exception("No email verification found.");
|
||||
}
|
||||
@@ -173,7 +173,7 @@ namespace Bit.Core.Services
|
||||
public string GetName()
|
||||
{
|
||||
var decoded = DecodeToken();
|
||||
if(decoded?["name"] == null)
|
||||
if (decoded?["name"] == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -183,7 +183,7 @@ namespace Bit.Core.Services
|
||||
public bool GetPremium()
|
||||
{
|
||||
var decoded = DecodeToken();
|
||||
if(decoded?["premium"] == null)
|
||||
if (decoded?["premium"] == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -193,7 +193,7 @@ namespace Bit.Core.Services
|
||||
public string GetIssuer()
|
||||
{
|
||||
var decoded = DecodeToken();
|
||||
if(decoded?["iss"] == null)
|
||||
if (decoded?["iss"] == null)
|
||||
{
|
||||
throw new Exception("No issuer found.");
|
||||
}
|
||||
@@ -208,7 +208,7 @@ namespace Bit.Core.Services
|
||||
// 63rd char of encoding
|
||||
output = output.Replace('_', '/');
|
||||
// Pad with trailing '='s
|
||||
switch(output.Length % 4)
|
||||
switch (output.Length % 4)
|
||||
{
|
||||
case 0:
|
||||
// No pad chars in this case
|
||||
|
||||
Reference in New Issue
Block a user