Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions MALClient.Desktop/Pages/Main/AnimeSearchPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using JikanDotNet;
using MALClient.Models.Enums;
using MALClient.XShared.NavArgs;
using MALClient.XShared.ViewModels;
Expand Down Expand Up @@ -89,8 +90,8 @@ private void UpperNavBarPivotOnSelectionChanged(object sender, SelectionChangedE

private void SelectionGridViewOnClick(object sender, ItemClickEventArgs e)
{
if(e.ClickedItem is AnimeGenres)
ViewModelLocator.GeneralMain.Navigate(PageIndex.PageAnimeList,new AnimeListPageNavigationArgs((AnimeGenres)e.ClickedItem));
if(e.ClickedItem is AnimeGenreSearch)
ViewModelLocator.GeneralMain.Navigate(PageIndex.PageAnimeList,new AnimeListPageNavigationArgs((AnimeGenreSearch)e.ClickedItem));
else
ViewModelLocator.GeneralMain.Navigate(PageIndex.PageAnimeList, new AnimeListPageNavigationArgs((AnimeStudios)e.ClickedItem));
}
Expand Down
38 changes: 34 additions & 4 deletions MALClient.Desktop/Pages/Main/LogInPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.Text.RegularExpressions;
using Windows.System;
using Windows.UI.Popups;
using Windows.UI.Xaml;
Expand All @@ -17,6 +18,7 @@ namespace MALClient.UWP.Pages.Main
public sealed partial class LogInPage : Page
{
private bool _headerSent;
private string _cookies;

public LogInPage()
{
Expand Down Expand Up @@ -62,6 +64,26 @@ private void SignInButtonClick(object sender, RoutedEventArgs e)
private void SignInWebViewOnNavigationStarting(WebView sender, WebViewNavigationStartingEventArgs args)
{
var targeturl = args.Uri.ToString();


if (targeturl.Contains("maloauth"))
{
try
{
var regex = new Regex(".*maloauth\\?code=(.*)\\&.*");
var match = regex.Matches(targeturl);
ViewModelLocator.LogIn.SignIn(_cookies, match[0].Groups[1].Value);
SignInWebView.Visibility = Visibility.Collapsed;
return;
}
catch
{
//error, display the error page?
args.Cancel = false;
return;
}
}


if (targeturl == "https://myanimelist.net/" ||
targeturl == "https://myanimelist.net/#" || //from google signi
Expand All @@ -71,9 +93,15 @@ private void SignInWebViewOnNavigationStarting(WebView sender, WebViewNavigation
var cookieCollection = filter.CookieManager.GetCookies(new Uri("https://myanimelist.net"));
var cookieString = cookieCollection.Aggregate("", (s, cookie) => s += $"{cookie.Name}={cookie.Value};");

ViewModelLocator.LogIn.SignIn(cookieString);

SignInWebView.Visibility = Visibility.Collapsed;
_cookies = cookieString;
var url = "https://myanimelist.net/v1/oauth2/authorize?response_type=code&" +
"client_id=183063f74126e7551b00c3b4de66986c&" +
"state=signin&" +
$"code_challenge={ViewModelLocator.LogIn.PkceChallenge}&" +
"code_challenge_method=plain";
Navigate(new Uri(url));


return;
}

Expand All @@ -96,7 +124,9 @@ private void SignInWebViewOnNavigationStarting(WebView sender, WebViewNavigation
targeturl.StartsWith("https://m.facebook") ||
targeturl.StartsWith("https://accounts.google") ||
targeturl.StartsWith("https://accounts.youtube") ||
targeturl.StartsWith("https://myanimelist.net/login.php"))
targeturl.StartsWith("https://myanimelist.net/login.php") ||
targeturl.StartsWith("https://myanimelist.net/submission/authorization") ||
targeturl.StartsWith("https://myanimelist.net/dialog/authorization"))
{
args.Cancel = false;
return;
Expand Down
5 changes: 3 additions & 2 deletions MALClient.Mobile/Pages/Main/AnimeSearchPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
using JikanDotNet;
using MALClient.Models.Enums;
using MALClient.XShared.NavArgs;
using MALClient.XShared.ViewModels;
Expand Down Expand Up @@ -41,8 +42,8 @@ protected override void OnNavigatedTo(NavigationEventArgs e)

private void SelectionGridViewOnClick(object sender, ItemClickEventArgs e)
{
if (e.ClickedItem is AnimeGenres)
ViewModelLocator.GeneralMain.Navigate(PageIndex.PageAnimeList, new AnimeListPageNavigationArgs((AnimeGenres)e.ClickedItem));
if (e.ClickedItem is AnimeGenreSearch)
ViewModelLocator.GeneralMain.Navigate(PageIndex.PageAnimeList, new AnimeListPageNavigationArgs((AnimeGenreSearch)e.ClickedItem));
else
ViewModelLocator.GeneralMain.Navigate(PageIndex.PageAnimeList, new AnimeListPageNavigationArgs((AnimeStudios)e.ClickedItem));
}
Expand Down