1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-17 16:53:26 +00:00

auth apis and api helpers

This commit is contained in:
Kyle Spearrin
2019-04-10 15:03:09 -04:00
parent 579a7e0398
commit 567161d8f3
3 changed files with 195 additions and 13 deletions

View File

@@ -10,8 +10,35 @@ namespace Bit.Core.Models.Request
public string Email { get; set; }
public string MasterPasswordHash { get; set; }
public string Token { get; set; }
public TwoFactorProviderType Provider { get; set; }
public TwoFactorProviderType? Provider { get; set; }
public bool Remember { get; set; }
public DeviceRequest Device { get; set; }
public Dictionary<string, string> ToIdentityToken(string clientId)
{
var obj = new Dictionary<string, string>
{
["grant_type"] = "password",
["username"] = Email,
["password"] = MasterPasswordHash,
["scope"] = "api offline_access",
["client_id"] = clientId
};
if(Device != null)
{
obj.Add("deviceType", ((int)Device.Type).ToString());
obj.Add("deviceIdentifier", Device.Identifier);
obj.Add("deviceName", Device.Name);
// TODO
// dict.Add("devicePushToken", null);
}
if(!string.IsNullOrWhiteSpace(Token) && Provider != null)
{
obj.Add("twoFactorToken", Token);
obj.Add("twoFactorProvider", ((int)Provider.Value).ToString());
obj.Add("twoFactorRemember", Remember ? "1" : "0");
}
return obj;
}
}
}