mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Multiple MEGA login fixes
This commit is contained in:
parent
3e71b072b2
commit
663b82f5a7
@ -4,7 +4,6 @@ using System.Reactive.Linq;
|
||||
using System.Security;
|
||||
using System.Threading.Tasks;
|
||||
using CG.Web.MegaApiClient;
|
||||
using Newtonsoft.Json;
|
||||
using ReactiveUI;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Common.Serialization.Json;
|
||||
@ -97,7 +96,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
|
||||
private static MegaApiClient MegaApiClient => DownloadDispatcher.GetInstance<MegaDownloader>().MegaApiClient;
|
||||
|
||||
private void MegaLogin()
|
||||
private static void MegaLogin()
|
||||
{
|
||||
if (MegaApiClient.IsLoggedIn)
|
||||
return;
|
||||
@ -132,7 +131,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
var fileLink = new Uri(Url);
|
||||
try
|
||||
{
|
||||
var node = MegaApiClient.GetNodeFromLink(fileLink);
|
||||
var node = await MegaApiClient.GetNodeFromLinkAsync(fileLink);
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Reactive;
|
||||
using System;
|
||||
using System.Net.Mail;
|
||||
using System.Reactive.Linq;
|
||||
using System.Security;
|
||||
using ReactiveUI;
|
||||
@ -26,7 +27,7 @@ namespace Wabbajack
|
||||
_downloader = downloader;
|
||||
|
||||
_loginEnabled = this.WhenAny(x => x.Username)
|
||||
.Select(username => !string.IsNullOrWhiteSpace(username))
|
||||
.Select(IsValidAddress)
|
||||
.ToGuiProperty(this,
|
||||
nameof(LoginEnabled));
|
||||
}
|
||||
@ -36,5 +37,22 @@ namespace Wabbajack
|
||||
ReturnMessage = _downloader.LoginWithCredentials(Username, password);
|
||||
password.Clear();
|
||||
}
|
||||
|
||||
private static bool IsValidAddress(string s)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(s))
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
var _ = new MailAddress(s);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user