bool IsAuthorised(string pin) { var login = userProfileService.GetByPin(pin); FormsAuthentication.SetAuthCookie(pin, true); var identity = new GenericIdentity(pin); if (login == null) { return(false); } Role role = roleService.GetDataById(login.RoleId); if (role.IsActive && login.IsActive) { //var unit = unitOfUserService.GetAllUnitsOfUserByUserProfileId(login.Id).FirstOrDefault(); //SessionHelper.DateFormat = "dd MMM, yyyy"; SessionHelper.UserName = login.UserName; SessionHelper.UserId = login.Id; //var tmp = userAccessListService.GetUserAccessListByUserProfileID(login.Id); //SessionHelper.Role = roleFeatureService.GetFeaturesByRoleID(login.RoleId); //SessionHelper.CanAccessAllDept = role.CanAccessAllDepartment; IEnumerable <QryRoleFeature> features = roleFeatureService.GetFeaturesByRoleID(role.Id); List <string> ftr = new List <string>(); if (features != null) { ftr = features.Select(c => c.Name).ToList(); } SessionHelper.Role = ftr; GenericPrincipal gp = new GenericPrincipal(identity, ftr.ToArray()); HttpContext.User = gp; SessionHelper.DefaultPage = role.RoleDefaultPage.PageUrl; return(true); } return(false); }
public ActionResult Index(int roleId) { ViewBag.RoleId = roleId; ViewBag.RoleName = roleService.GetDataById(roleId).RoleName; return(View(roleFeatureService.GetFeaturesByRoleID(roleId).OrderBy(r => r.Name))); }