Merge remote-tracking branch 'origin/xamarin-fix-uwp-login' into dev

This commit is contained in:
Eduard Tomas 2017-03-31 17:52:23 +02:00
commit 47b7cabdcd
10 changed files with 54 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -14,6 +14,7 @@ namespace Microsoft.eShopOnContainers.BuildingBlocks.Resilience.HttpResilience
/// <summary>
/// HttpClient wrapper that integrates Retry and Circuit
/// breaker policies when invoking HTTP services.
/// Based on Polly library: https://github.com/App-vNext/Polly
/// </summary>
public class ResilientHttpClient : IHttpClient
{

View File

@ -107,6 +107,7 @@
<converters:ItemsToHeightConverter x:Key="ItemsToHeightConverter" />
<converters:ToUpperConverter x:Key="ToUpperConverter" />
<converters:WebNavigatingEventArgsConverter x:Key="WebNavigatingEventArgsConverter" />
<converters:WebNavigatedEventArgsConverter x:Key="WebNavigatedEventArgsConverter" />
<!-- STYLES -->
<Style x:Key="EntryStyle"

View File

@ -0,0 +1,23 @@
using System;
using System.Globalization;
using Xamarin.Forms;
namespace eShopOnContainers.Core.Converters
{
public class WebNavigatedEventArgsConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var eventArgs = value as WebNavigatedEventArgs;
if (eventArgs == null)
throw new ArgumentException("Expected WebNavigatedEventArgs as value", "value");
return eventArgs.Url;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -60,7 +60,7 @@
IdentityEndpoint = string.Format("{0}:5105/connect/authorize", baseEndpoint);
UserInfoEndpoint = string.Format("{0}:5105/connect/userinfo", baseEndpoint);
LogoutEndpoint = string.Format("{0}:5105/connect/endsession", baseEndpoint);
IdentityCallback = "http://eshopxamarin/callback.html";
IdentityCallback = string.Format("{0}:5105/xamarincallback", baseEndpoint);
LogoutCallback = string.Format("{0}:5105/Account/Redirecting", baseEndpoint);
}
}

View File

@ -221,14 +221,16 @@ namespace eShopOnContainers.Core.ViewModels
private async Task NavigateAsync(string url)
{
if (url.Equals(GlobalSetting.Instance.LogoutCallback))
var unescapedUrl = System.Net.WebUtility.UrlDecode(url);
if (unescapedUrl.Equals(GlobalSetting.Instance.LogoutCallback))
{
Settings.AuthAccessToken = string.Empty;
Settings.AuthIdToken = string.Empty;
IsLogin = false;
LoginUrl = _identityService.CreateAuthorizeRequest();
}
else if (url.Contains(GlobalSetting.Instance.IdentityCallback))
else if (unescapedUrl.Contains(GlobalSetting.Instance.IdentityCallback))
{
var authResponse = new AuthorizeResponse(url);

View File

@ -313,10 +313,26 @@
AbsoluteLayout.LayoutBounds="0, 0, 1, 1"
AbsoluteLayout.LayoutFlags="All">
<WebView.Behaviors>
<OnPlatform x:TypeArguments="Behavior">
<OnPlatform.Android>
<behaviors:EventToCommandBehavior
EventName="Navigating"
EventArgsConverter="{StaticResource WebNavigatingEventArgsConverter}"
Command="{Binding NavigateCommand}" />
</OnPlatform.Android>
<OnPlatform.iOS>
<behaviors:EventToCommandBehavior
EventName="Navigating"
EventArgsConverter="{StaticResource WebNavigatingEventArgsConverter}"
Command="{Binding NavigateCommand}" />
</OnPlatform.iOS>
<OnPlatform.WinPhone>
<behaviors:EventToCommandBehavior
EventName="Navigated"
EventArgsConverter="{StaticResource WebNavigatedEventArgsConverter}"
Command="{Binding NavigateCommand}" />
</OnPlatform.WinPhone>
</OnPlatform>
</WebView.Behaviors>
</WebView>
</AbsoluteLayout>

View File

@ -58,6 +58,7 @@
<Compile Include="Converters\ItemsToHeightConverter.cs" />
<Compile Include="Converters\ItemTappedEventArgsConverter.cs" />
<Compile Include="Converters\ToUpperConverter.cs" />
<Compile Include="Converters\WebNavigatedEventArgsConverter.cs" />
<Compile Include="Effects\LineColorEffect.cs" />
<Compile Include="Exceptions\ServiceAuthenticationException.cs" />
<Compile Include="Extensions\AnimationExtension.cs" />

View File

@ -24,5 +24,6 @@
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="privateNetworkClientServer" />
</Capabilities>
</Package>