summaryrefslogtreecommitdiffstats
path: root/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.cs
blob: 4ffb9b80c29f3f96539af13e9a931c69f327e271 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//-----------------------------------------------------------------------
// <copyright file="OAuthAuthorize.aspx.cs" company="Andrew Arnott">
//     Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace WebFormsRelyingParty.Members {
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Web;
	using System.Web.UI;
	using System.Web.UI.WebControls;
	using DotNetOpenAuth.OAuth;
	using DotNetOpenAuth.OAuth.Messages;
	using WebFormsRelyingParty.Code;

	public partial class OAuthAuthorize : System.Web.UI.Page {
		protected void Page_Load(object sender, EventArgs e) {
			if (!IsPostBack) {
				if (OAuthServiceProvider.PendingAuthorizationRequest == null) {
					Response.Redirect("~/");
				}

				this.csrfCheck.Value = Utilities.SetCsrfCookie();
				this.consumerNameLabel.Text = HttpUtility.HtmlEncode(OAuthServiceProvider.PendingAuthorizationConsumer.Name);
			} else {
				Utilities.VerifyCsrfCookie(this.csrfCheck.Value);
			}
		}

		protected void yesButton_Click(object sender, EventArgs e) {
			OAuthServiceProvider.AuthorizePendingRequestToken();
		}

		protected void noButton_Click(object sender, EventArgs e) {
			OAuthServiceProvider.PendingAuthorizationRequest = null;
			Response.Redirect("~/");
		}
	}
}