public Logon Authenticate([FromBody] Logon loginInfo) { var errors = new List <string>(); IAuthorizeRepository authorize = new AuthorizeRepository(); return(new AuthorizeService(authorize).Authenticate(loginInfo.UserName, loginInfo.Password, ref errors)); }
private void DoAthorizeOnToolBarItems() { IAuthorizeRepository athorizeRep = new AuthorizeRepository(); foreach (ToolBarItem item in toolbarItems) { string controlId = item.ID.ToString().ToLower(); int denyCount = accessDeniedList.Where(x => x.ResourceID.ToLower().Equals(controlId)).Count(); //if (denyCount > 1) //{ // throw new InvalidDatabaseStateException(UIFatalExceptionIdentifiers.ResourceControlsWithRepeatedId, String.Format("Control ID more than one was found!:{0}", controlId), "GTSBasePage"); //} //دسترسی به یک آیتم مشابه مانند اعتبار سنجی قوانین که شناسه کنترل //یکسان دارد را نمایش میدهیم با نامسرویس اعتبارسنجی میکنیم if (denyCount >= 1) { int allowCount = accessAllowedResourceList.Where(x => x.ResourceID.ToLower().Equals(controlId)).Count(); if (allowCount > 0) { continue; } else { item.ParentToolBar.Items.Remove(item); } } } }
public Logon Authenticate(string email, string password) { var errors = new List <string>(); IAuthorizeRepository authorize = new AuthorizeRepository(); return(new AuthorizeService(authorize).Authenticate(email, password, ref errors)); }
public IList <Resource> GetAlowedResourceList(decimal roleId) { AuthorizeRepository athorizeRep = new AuthorizeRepository(); string extension = roleId.ToString(); IList <Resource> list = new List <Resource>(); if (!SessionHelper.HasSessionValue(SessionHelper.BussinessSecurityAllResourceList + extension)) { list = athorizeRep.GetAccessAllowed(roleId); if (list != null && list.Count > 0) { SessionHelper.SaveSessionValue(SessionHelper.BussinessSecurityAllResourceList + extension, list); } else { SessionHelper.ClearSessionValue(SessionHelper.BussinessSecurityAllResourceList + extension); } } object obj = SessionHelper.GetSessionValue(SessionHelper.BussinessSecurityAllResourceList + extension); if (obj != null) { list = (IList <Resource>)obj; } return(list); }
public void GetAllRoleFeatures_Test_Null() { var options = new DbContextOptionsBuilder <AuthorizeDbContext>() .UseInMemoryDatabase("GetAllRoleFeatures_Test_Null") .Options; var context = new AuthorizeDbContext(options); var repository = new AuthorizeRepository(context); var roleFeatures = repository.GetAllRoleFeatures(); roleFeatures.Count().Should().Be(0); context.RoleFeatures.FirstOrDefault().Should().BeNull(); }
// GET: Authorize public ActionResult Index(string UserId, string Password) { AuthorizeModel oAuthorizeModel = new AuthorizeModel(); AuthorizeRepository oAuthorizeRepository = new AuthorizeRepository(); if (UserId == "*****@*****.**" && Password == "admin@123") { return(View("Admin")); } else if (UserId == "*****@*****.**" && Password == "customer@123") { return(View("Customer")); } else if (UserId == "*****@*****.**" && Password == "employee@123") { return(View("Employee")); } else { return(View()); } }
public void GetAllRoleFeatures_Test_Success() { var options = new DbContextOptionsBuilder <AuthorizeDbContext>() .UseInMemoryDatabase("GetAllRoleFeatures_Test_Success") .Options; using (var context = new AuthorizeDbContext(options)) { var feature = new Feature { Id = 1, Name = "test feature", Description = "test desc" }; context.Features.Add(feature); var role = new Role { Id = 1, Name = "test role", Description = "test desc" }; context.Roles.Add(role); context.RoleFeatures.Add(new RoleFeature { Id = 1, FeatureId = 1, Role = role, Feature = feature }); context.SaveChanges(); } var repository = new AuthorizeRepository(new AuthorizeDbContext(options)); var roleFeatures = repository.GetAllRoleFeatures(); roleFeatures.Count().Should().Be(1); var roleFeature = roleFeatures.FirstOrDefault(); roleFeature.Should().NotBeNull(); roleFeature.RoleId.Should().Be(1); roleFeature.FeatureId.Should().Be(1); roleFeature.Feature.Should().NotBeNull(); roleFeature.Role.Should().NotBeNull(); }
/// <summary> /// یک آیتم در صورتی نمایش داده میشود که سه شرط را دارا باشد /// * جزو عدم دسترسی نباشد /// ** باید آن آیتم حتما جزو دسترسی داده شده ها باشد /// ** کد چک آن درست باشد /// </summary> private void DoAthorizeOnNavBarItems() { IAuthorizeRepository athorizeRep = new AuthorizeRepository(); if (this.AccessNotAllowdNavBarItemsList == null) { this.AccessNotAllowdNavBarItemsList = new List <NavBarItem>(); } foreach (NavBarItem item in NavBarItems) { string controlId = item.ID.ToString().ToLower(); //int denyCount = accessDeniedList.Where(x => x.ResourceID.ToLower().Equals(controlId)).Count(); //int allowedCount = accessAllowedResourceList.Where(x => x.ResourceID.ToLower().Equals(controlId)).Count();//باید در لیست اجازه داده شده ها هم موجود باشد Resource resource = accessAllowedResourceList.Where(x => x.ResourceID.ToLower().Equals(controlId)).FirstOrDefault(); /*allowedCount = 1;*/ /* if (denyCount > 1) * { * throw new InvalidDatabaseStateException(UIFatalExceptionIdentifiers.ResourceControlsWithRepeatedId, String.Format("Control ID more than one was found!:{0}", controlId), "GTSBasePage"); * }*/ //if (denyCount == 1 || allowedCount == 0) if (resource == null /*|| !Utility.VerifyHashCode(resource.ResourceID, resource.CheckKey)*/) { if (item.ParentItem != null) { this.AccessNotAllowdNavBarItemsList.Add(item); ((NavBarItem)(item.ParentItem)).Items.Remove(item); } else if (item.ParentNavBar != null) { ((NavBar)(item.ParentNavBar)).Items.Remove(item); } } } }