summaryrefslogtreecommitdiffstats
path: root/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-11-12 23:52:27 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2009-11-12 23:52:27 -0800
commit6c7a41277312bfc42aabf5ecbe5fc58e99243f37 (patch)
treeaa432a97b2c7db8532939fd43c7faccca62e2488 /projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.cs
parentf7c578cc7c7713de3348a839d0d9caeba643a33d (diff)
downloadDotNetOpenAuth-6c7a41277312bfc42aabf5ecbe5fc58e99243f37.zip
DotNetOpenAuth-6c7a41277312bfc42aabf5ecbe5fc58e99243f37.tar.gz
DotNetOpenAuth-6c7a41277312bfc42aabf5ecbe5fc58e99243f37.tar.bz2
Fixed a bunch of bugs in the project template's oauth sp implementation.
Diffstat (limited to 'projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.cs')
-rw-r--r--projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.cs26
1 files changed, 24 insertions, 2 deletions
diff --git a/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.cs b/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.cs
index 4ffb9b8..2969d7c 100644
--- a/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.cs
+++ b/projecttemplates/WebFormsRelyingParty/Members/OAuthAuthorize.aspx.cs
@@ -18,24 +18,46 @@ namespace WebFormsRelyingParty.Members {
public partial class OAuthAuthorize : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
if (!IsPostBack) {
- if (OAuthServiceProvider.PendingAuthorizationRequest == null) {
+ var pendingRequest = OAuthServiceProvider.PendingAuthorizationRequest;
+ if (pendingRequest == null) {
Response.Redirect("~/");
}
this.csrfCheck.Value = Utilities.SetCsrfCookie();
this.consumerNameLabel.Text = HttpUtility.HtmlEncode(OAuthServiceProvider.PendingAuthorizationConsumer.Name);
+ OAuth10ConsumerWarning.Visible = pendingRequest.IsUnsafeRequest;
} else {
Utilities.VerifyCsrfCookie(this.csrfCheck.Value);
}
}
protected void yesButton_Click(object sender, EventArgs e) {
+ outerMultiView.SetActiveView(authorizationGrantedView);
+
+ var consumer = OAuthServiceProvider.PendingAuthorizationConsumer;
+ var tokenManager = OAuthServiceProvider.ServiceProvider.TokenManager;
+ var pendingRequest = OAuthServiceProvider.PendingAuthorizationRequest;
+ ITokenContainingMessage requestTokenMessage = pendingRequest;
+ var requestToken = tokenManager.GetRequestToken(requestTokenMessage.Token);
+
OAuthServiceProvider.AuthorizePendingRequestToken();
+
+ // The rest of this method only executes if we couldn't automatically
+ // redirect to the consumer.
+ if (pendingRequest.IsUnsafeRequest) {
+ verifierMultiView.SetActiveView(noCallbackView);
+ } else {
+ verifierMultiView.SetActiveView(verificationCodeView);
+ string verifier = ServiceProvider.CreateVerificationCode(consumer.VerificationCodeFormat, consumer.VerificationCodeLength);
+ verificationCodeLabel.Text = verifier;
+ requestToken.VerificationCode = verifier;
+ tokenManager.UpdateToken(requestToken);
+ }
}
protected void noButton_Click(object sender, EventArgs e) {
+ outerMultiView.SetActiveView(authorizationDeniedView);
OAuthServiceProvider.PendingAuthorizationRequest = null;
- Response.Redirect("~/");
}
}
}