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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user