/// <summary> /// if the user is in any one of the validRoleNames, authentication will proceed. /// </summary> /// <param name="context"></param> /// <param name="validRoleNames"></param> /// <returns></returns> public bool CheckAuthentication(HttpContext context, string[] validRoleNames, PortalApplication portalApp) { var IsValid = false; if (WebPortalUser.CheckLogin(_un, _pw, portalApp)) { WebPortalUser u = WebPortalUser.FetchUser(_un, portalApp); foreach (string requiredRoleName in validRoleNames) { bool b = u.inRole(requiredRoleName); if (b) { Roles.Add(requiredRoleName); IsValid = true; } } if (IsValid) { u.SetLastLoginInDatabaseToNow(); return(true); } } return(false); }
public bool CheckAuthentication(HttpContext context, string requiredRoleName, PortalApplication portalApp) { if (WebPortalUser.CheckLogin(_un, _pw, portalApp)) { WebPortalUser u = WebPortalUser.FetchUser(_un, portalApp); bool b = u.inRole(requiredRoleName); if (b) { u.SetLastLoginInDatabaseToNow(); return(true); } } return(false); }
/// <summary> /// Checks whether a user has write access in this zone. /// </summary> /// <param name="u"></param> /// <returns></returns> public bool canWrite(WebPortalUser u) { if (u != null && u.inRole(CmsConfig.getConfigValue("AdminUserRole", "Administrator"))) { return(true); } WebPortalUserRole[] roleArray = new WebPortalUserRole[] { WebPortalUserRole.dummyPublicUserRole }; if (u != null) { u.AddUserRole(WebPortalUserRole.dummyPublicUserRole); // users are always part of the "public" user role. roleArray = u.userRoles; } CmsZoneUserRoleDb db = new CmsZoneUserRoleDb(); return(db.fetchRoleMatchingCountForWrite(this, roleArray) > 0); }