2 using System
.Collections
.Generic
;
5 using System
.Web
.Security
;
6 using PumpkinHouseDatabase
;
10 public class RoleProvider
: SqlRoleProvider
12 public override bool IsUserInRole(string username
, string roleName
)
14 if (roleName
== "admin")
16 using (DataUtils utils
= new DataUtils(false))
18 DB_User user
= utils
.FindUserByNameOrEmail(username
);
23 return user
.Is_Admin
== 1;
26 if (roleName
== "locked")
28 using (DataUtils utils
= new DataUtils(false))
30 DB_User user
= utils
.FindUserByNameOrEmail(username
);
35 if (user
.Is_Locked
== 1)
37 HttpContext
.Current
.Session
["username"] = user
.Username
;
38 HttpContext
.Current
.Session
["lockedReason"] = user
.Locked_Reason
;
47 public override string[] GetRolesForUser(string username
)
49 using (DataUtils utils
= new DataUtils(false))
51 DB_User user
= utils
.FindUserByNameOrEmail(username
);
52 if (user
.Is_Locked
== 1)
54 return new string[] { "locked" }
;
56 if (user
.Is_Admin
== 1)
58 return new string[] { "admin" }
;
60 return new string[] { }
;
64 public override string[] GetAllRoles()
66 return new string[] { "admin", "locked" }
;