diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2009-03-26 14:04:40 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2009-03-26 14:04:40 -0700 |
commit | d7bec791ff0b1fe6517c2b450d6fd1116d0a8ea7 (patch) | |
tree | 019bb8c875e2fa9c5ca07bb17af17891411307cf /samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx.cs | |
parent | 540f088953154bee2356cdf5f65a097cb6d3ebe4 (diff) | |
download | DotNetOpenAuth-d7bec791ff0b1fe6517c2b450d6fd1116d0a8ea7.zip DotNetOpenAuth-d7bec791ff0b1fe6517c2b450d6fd1116d0a8ea7.tar.gz DotNetOpenAuth-d7bec791ff0b1fe6517c2b450d6fd1116d0a8ea7.tar.bz2 |
Renamed OpenID RP sample projects.
Diffstat (limited to 'samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx.cs')
-rw-r--r-- | samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx.cs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx.cs b/samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx.cs new file mode 100644 index 0000000..ffaf6f0 --- /dev/null +++ b/samples/OpenIdRelyingPartyWebForms/ajaxlogin.aspx.cs @@ -0,0 +1,56 @@ +namespace OpenIdRelyingPartyWebForms { + using System; + using System.Web.UI.WebControls; + using DotNetOpenAuth.OpenId.Extensions.SimpleRegistration; + using DotNetOpenAuth.OpenId.RelyingParty; + + public partial class ajaxlogin : System.Web.UI.Page { + protected void Page_Load(object sender, EventArgs e) { + if (!IsPostBack) { + this.OpenIdAjaxTextBox1.Focus(); + } + } + + protected void OpenIdAjaxTextBox1_LoggingIn(object sender, OpenIdEventArgs e) { + e.Request.AddExtension(new ClaimsRequest { + Email = DemandLevel.Request, + }); + } + + protected void OpenIdAjaxTextBox1_LoggedIn(object sender, OpenIdEventArgs e) { + Label label = ((Label)this.commentSubmitted.FindControl("emailLabel")); + label.Text = e.Response.FriendlyIdentifierForDisplay; + + // We COULD get the sreg extension response here for the email, but since we let the user + // potentially change the email in the HTML form, we'll use that instead. + ////var claims = OpenIdAjaxTextBox1.AuthenticationResponse.GetExtension<ClaimsResponse>(); + if (this.emailAddressBox.Text.Length > 0) { + label.Text += " (" + this.emailAddressBox.Text + ")"; + } + } + + protected void submitButton_Click(object sender, EventArgs e) { + if (!Page.IsValid) { + return; + } + if (this.OpenIdAjaxTextBox1.AuthenticationResponse != null) { + if (this.OpenIdAjaxTextBox1.AuthenticationResponse.Status == AuthenticationStatus.Authenticated) { + // Save comment here! + this.multiView.ActiveViewIndex = 1; + } else { + this.multiView.ActiveViewIndex = 2; + } + } + } + + protected void editComment_Click(object sender, EventArgs e) { + this.multiView.ActiveViewIndex = 0; + } + + protected void OpenIdAjaxTextBox1_UnconfirmedPositiveAssertion(object sender, OpenIdEventArgs e) { + // This is where we register extensions that we want to have available in javascript + // on the browser. + this.OpenIdAjaxTextBox1.RegisterClientScriptExtension<ClaimsResponse>("sreg"); + } + } +} |