Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/aspnetwebstack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryaohuang <yaohuang@microsoft.com>2012-10-20 03:34:08 +0400
committeryaohuang <yaohuang@microsoft.com>2012-10-22 23:15:33 +0400
commit85576dea0899a60549bc1e447e2828bb66640563 (patch)
tree0eeec0b1175cbf0cb44fcb418b741231cac01178
parent19d6987f2bfb3a43257ba46e256b06233d095c44 (diff)
Facebook Template Updates:
* removed more unused packages * fixed an issue where using the default FacebookAuthorizeAttribute causes error * made the facebook app URL configurable * removed the unnecessary app.config
-rw-r--r--src/Microsoft.AspNet.Mvc.Facebook/App.config14
-rw-r--r--src/Microsoft.AspNet.Mvc.Facebook/Attributes/FacebookAuthorizeAttribute.cs28
-rw-r--r--src/Microsoft.AspNet.Mvc.Facebook/Microsoft.AspNet.Mvc.Facebook.csproj3
-rw-r--r--src/Microsoft.AspNet.Mvc.Facebook/Services/FacebookSettings.cs14
-rw-r--r--src/Microsoft.AspNet.Mvc.Facebook/packages.config2
5 files changed, 34 insertions, 27 deletions
diff --git a/src/Microsoft.AspNet.Mvc.Facebook/App.config b/src/Microsoft.AspNet.Mvc.Facebook/App.config
deleted file mode 100644
index 03e57ddd..00000000
--- a/src/Microsoft.AspNet.Mvc.Facebook/App.config
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
- <configSections>
- <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
- <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
- </configSections>
- <entityFramework>
- <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
- <parameters>
- <parameter value="v11.0" />
- </parameters>
- </defaultConnectionFactory>
- </entityFramework>
-</configuration> \ No newline at end of file
diff --git a/src/Microsoft.AspNet.Mvc.Facebook/Attributes/FacebookAuthorizeAttribute.cs b/src/Microsoft.AspNet.Mvc.Facebook/Attributes/FacebookAuthorizeAttribute.cs
index fdf1b4e9..753d8774 100644
--- a/src/Microsoft.AspNet.Mvc.Facebook/Attributes/FacebookAuthorizeAttribute.cs
+++ b/src/Microsoft.AspNet.Mvc.Facebook/Attributes/FacebookAuthorizeAttribute.cs
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
+using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Mvc;
@@ -37,9 +39,9 @@ namespace Microsoft.AspNet.Mvc.Facebook.Attributes
// https://developers.facebook.com/docs/reference/dialogs/oauth/#parameters
FacebookAuthorizationInfo authInfo;
- if (!String.IsNullOrWhiteSpace(this.Permissions))
+ if (!String.IsNullOrWhiteSpace(Permissions))
{
- var permissions = this.Permissions.Split(',').Select((s) => s.Trim()).ToArray();
+ var permissions = Permissions.Split(',').Select(s => s.Trim()).ToArray();
authInfo = _facebookService.Authorize(filterContext.HttpContext, permissions);
}
else
@@ -64,13 +66,23 @@ namespace Microsoft.AspNet.Mvc.Facebook.Attributes
{
appPath = FacebookSettings.AppId;
}
- var redirectUri = "https://apps.facebook.com/" + appPath + filterContext.HttpContext.Request.Url.PathAndQuery;
- var loginUrl = client.GetLoginUrl(new
+
+ var redirectUri = String.Format(CultureInfo.InvariantCulture,
+ "{0}/{1}{2}",
+ FacebookSettings.FacebookAppUrl.TrimEnd('/'),
+ appPath,
+ filterContext.HttpContext.Request.Url.PathAndQuery);
+
+ Dictionary<string, object> loginUrlParameters = new Dictionary<string, object>();
+ loginUrlParameters["redirect_uri"] = redirectUri;
+ loginUrlParameters["client_id"] = FacebookSettings.AppId;
+ if (!String.IsNullOrWhiteSpace(Permissions))
{
- scope = this.Permissions,
- redirect_uri = redirectUri,
- client_id = FacebookSettings.AppId
- });
+ loginUrlParameters["scope"] = Permissions;
+ }
+
+ var loginUrl = client.GetLoginUrl(loginUrlParameters);
+
var facebookAuthResult = new ContentResult();
facebookAuthResult.ContentType = "text/html";
facebookAuthResult.Content = String.Format("<script>window.top.location = '{0}';</script>", loginUrl.AbsoluteUri);
diff --git a/src/Microsoft.AspNet.Mvc.Facebook/Microsoft.AspNet.Mvc.Facebook.csproj b/src/Microsoft.AspNet.Mvc.Facebook/Microsoft.AspNet.Mvc.Facebook.csproj
index d64ee40d..d9acd249 100644
--- a/src/Microsoft.AspNet.Mvc.Facebook/Microsoft.AspNet.Mvc.Facebook.csproj
+++ b/src/Microsoft.AspNet.Mvc.Facebook/Microsoft.AspNet.Mvc.Facebook.csproj
@@ -128,9 +128,6 @@
</Compile>
</ItemGroup>
<ItemGroup>
- <None Include="App.config">
- <SubType>Designer</SubType>
- </None>
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
diff --git a/src/Microsoft.AspNet.Mvc.Facebook/Services/FacebookSettings.cs b/src/Microsoft.AspNet.Mvc.Facebook/Services/FacebookSettings.cs
index a79ecc2a..11ff4c57 100644
--- a/src/Microsoft.AspNet.Mvc.Facebook/Services/FacebookSettings.cs
+++ b/src/Microsoft.AspNet.Mvc.Facebook/Services/FacebookSettings.cs
@@ -6,6 +6,8 @@ namespace Microsoft.AspNet.Mvc.Facebook.Services
{
public static class FacebookSettings
{
+ private static string _facebookAppUrl = "https://apps.facebook.com";
+
static FacebookSettings()
{
DefaultUserStorageService = DefaultFacebookUserStorageService.Instance;
@@ -21,6 +23,17 @@ namespace Microsoft.AspNet.Mvc.Facebook.Services
public static IFacebookUserStorageService DefaultUserStorageService { get; set; }
public static IFacebookObjectStorageService DefaultObjectStorageService { get; set; }
+ public static string FacebookAppUrl
+ {
+ get
+ {
+ return _facebookAppUrl;
+ }
+ set
+ {
+ _facebookAppUrl = value;
+ }
+ }
public static void LoadFromConfig()
{
@@ -28,6 +41,7 @@ namespace Microsoft.AspNet.Mvc.Facebook.Services
AppSecret = ConfigurationManager.AppSettings["Facebook.AppSecret"];
AppNamespace = ConfigurationManager.AppSettings["Facebook.AppNamespace"];
RealtimeCallbackUrl = ConfigurationManager.AppSettings["Facebook.RealtimeCallbackUrl"];
+ FacebookAppUrl = ConfigurationManager.AppSettings["Facebook.FacebookAppUrl"] ?? _facebookAppUrl;
}
}
}
diff --git a/src/Microsoft.AspNet.Mvc.Facebook/packages.config b/src/Microsoft.AspNet.Mvc.Facebook/packages.config
index 849f5774..3ffbe3ec 100644
--- a/src/Microsoft.AspNet.Mvc.Facebook/packages.config
+++ b/src/Microsoft.AspNet.Mvc.Facebook/packages.config
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
- <package id="AspNetMvc" version="4.0.20710.0" targetFramework="net40" />
- <package id="AspNetWebApi" version="4.0.20710.0" targetFramework="net40" />
<package id="EntityFramework" version="5.0.0" targetFramework="net40" />
<package id="Facebook" version="6.0.24" targetFramework="net40" />
<package id="Microsoft.AspNet.Mvc" version="4.0.20710.0" targetFramework="net40" />