-
Notifications
You must be signed in to change notification settings - Fork 0
/
SecuredGadgetPage.cs
50 lines (46 loc) · 1.38 KB
/
SecuredGadgetPage.cs
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
42
43
44
45
46
47
48
49
50
using System;
using System.Web;
using System.Web.Security;
using Seattle.DoIT.PoliceReports.Web.UserProfileServices;
namespace Seattle.DoIT.PoliceReports.Web.UI
{
public class SecuredGadgetPage : System.Web.UI.Page
{
private UserProfile _userProfile = null;
protected override void OnLoad(EventArgs e)
{
if (!Page.User.Identity.IsAuthenticated)
{
SiteNavigator.RedirectToSignInRequiredGadgetPage();
}
else
{
UserProfile userProfile = UserProfile;
if (userProfile == null)
{
SiteNavigator.RedirectToUserRegistrationGadgetPage(Page.AppRelativeVirtualPath.Remove(0,1));
}
else if (!userProfile.IsActive)
{
SiteNavigator.RedirectToAccessRevokedGadgetPage();
}
}
base.OnLoad(e);
}
internal UserProfile UserProfile
{
get
{
if (_userProfile == null && Page.User.Identity.IsAuthenticated)
{
UserProfileService svc = UserProfileServiceFactory.Create();
using (svc as IDisposable)
{
_userProfile = svc.GetByUserName(Page.User.Identity.Name);
}
}
return _userProfile;
}
}
}
}