Re-added support for token-only logins
This commit is contained in:
@@ -5,14 +5,14 @@ namespace Discord.API.Client.Rest
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public sealed class LoginRequest : IRestRequest<LoginResponse>
|
||||
{
|
||||
string IRestRequest.Method => "POST";
|
||||
string IRestRequest.Method => Email != null ? "POST" : "GET";
|
||||
string IRestRequest.Endpoint => $"auth/login";
|
||||
object IRestRequest.Payload => this;
|
||||
bool IRestRequest.IsPrivate => false;
|
||||
|
||||
[JsonProperty("email")]
|
||||
[JsonProperty("email", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string Email { get; set; }
|
||||
[JsonProperty("password")]
|
||||
[JsonProperty("password", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public string Password { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -168,13 +168,13 @@ namespace Discord
|
||||
await BeginConnect(email, password, null).ConfigureAwait(false);
|
||||
return ClientAPI.Token;
|
||||
}
|
||||
/*/// <summary> Connects to the Discord server with the provided token. </summary>
|
||||
/// <summary> Connects to the Discord server with the provided token. </summary>
|
||||
public async Task Connect(string token)
|
||||
{
|
||||
if (token == null) throw new ArgumentNullException(token);
|
||||
|
||||
await BeginConnect(null, null, token).ConfigureAwait(false);
|
||||
}*/
|
||||
}
|
||||
|
||||
private async Task BeginConnect(string email, string password, string token = null)
|
||||
{
|
||||
@@ -222,7 +222,7 @@ namespace Discord
|
||||
throw;
|
||||
}
|
||||
}
|
||||
private async Task Login(string email, string password, string token = null)
|
||||
private async Task Login(string email = null, string password = null, string token = null)
|
||||
{
|
||||
string tokenPath = null, oldToken = null;
|
||||
byte[] cacheKey = null;
|
||||
|
||||
@@ -208,7 +208,7 @@ namespace Discord
|
||||
/// <summary> Returns if this message was sent from the logged-in accounts. </summary>
|
||||
public bool IsAuthor => User != null && User.Id == Client.CurrentUser?.Id;
|
||||
|
||||
internal Message(ulong id, Channel channel, User user)
|
||||
internal Message(ulong id, Channel channel, User user)
|
||||
{
|
||||
Id = id;
|
||||
Channel = channel;
|
||||
|
||||
Reference in New Issue
Block a user