diff options
Diffstat (limited to 'samples/TestAzureAD/Account/OpenAuthProviders.ascx.cs')
-rw-r--r-- | samples/TestAzureAD/Account/OpenAuthProviders.ascx.cs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/samples/TestAzureAD/Account/OpenAuthProviders.ascx.cs b/samples/TestAzureAD/Account/OpenAuthProviders.ascx.cs new file mode 100644 index 0000000..2058c27 --- /dev/null +++ b/samples/TestAzureAD/Account/OpenAuthProviders.ascx.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Web; +using Microsoft.AspNet.Membership.OpenAuth; + +namespace TestAzureAD.Account +{ + public partial class OpenAuthProviders : System.Web.UI.UserControl + { + protected void Page_Load(object sender, EventArgs e) + { + + if (IsPostBack) + { + var provider = Request.Form["provider"]; + if (provider == null) + { + return; + } + + var redirectUrl = "~/Account/RegisterExternalLogin.aspx"; + if (!String.IsNullOrEmpty(ReturnUrl)) + { + var resolvedReturnUrl = ResolveUrl(ReturnUrl); + redirectUrl += "?ReturnUrl=" + HttpUtility.UrlEncode(resolvedReturnUrl); + } + + OpenAuth.RequestAuthentication(provider, redirectUrl); + } + } + + + + public string ReturnUrl { get; set; } + + + public IEnumerable<ProviderDetails> GetProviderNames() + { + return OpenAuth.AuthenticationClients.GetAll(); + } + + } +}
\ No newline at end of file |