summaryrefslogtreecommitdiffstats
path: root/projecttemplates/WebFormsRelyingParty/Setup.aspx.cs
blob: 22125a42c2a3267a7e00c9701fd52e1937dac829 (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
namespace WebFormsRelyingParty {
	using System;
	using System.Collections.Generic;
	using System.Globalization;
	using System.IO;
	using System.Linq;
	using System.Web;
	using System.Web.UI;
	using System.Web.UI.WebControls;
	using DotNetOpenAuth.OpenId;
	using DotNetOpenAuth.OpenId.RelyingParty;
	using RelyingPartyLogic;

	public partial class Setup : System.Web.UI.Page {
		private bool databaseCreated;

		protected void Page_Load(object sender, EventArgs e) {
			if (!Page.IsPostBack) {
				this.openidLogin.Focus();
			}
		}

		protected void openidLogin_LoggingIn(object sender, OpenIdEventArgs e) {
			// We don't actually want to log in... we just want the claimed identifier.
			e.Cancel = true;
			if (e.IsDirectedIdentity) {
				this.noOPIdentifierLabel.Visible = true;
			} else if (!this.databaseCreated) {
				Utilities.CreateDatabase(e.ClaimedIdentifier, this.openidLogin.Text);
				this.MultiView1.ActiveViewIndex = 1;

				// indicate we have already created the database so that if the
				// identifier the user gave has multiple service endpoints,
				// we won't try to recreate the database as the next one is considered.
				this.databaseCreated = true;
			}
		}
	}
}