protected override bool AuthorizeCore(HttpContextBase httpContext) { bool superAdmin = false; bool isAdmin = false; bool isuser = false; IserviceAdmin spa = new serviceAdmin(); IPrincipal user = httpContext.User; bool authorize = false; string userid = user.Identity.Name; Admin _admin = spa.Get(x => x.mailAdmin == userid); if (_admin == null) { IserviceUser spu = new serviceUser(); User _user = new User(); _user = spu.Get(x => x.username == userid); if (_user != null) { isuser = true; } } else if (_admin != null) { if (_admin.isSuperAdmin) { superAdmin = true; } else { isAdmin = true; } } if (superAdmin && Roles.Contains("SuperAdmin")) { authorize = true; } if (isAdmin && Roles.Contains("SuperAdmin,Admin")) { authorize = true; } if (isuser && this.Roles.Contains("User")) { authorize = true; } return(authorize); }
protected override bool AuthorizeCore(HttpContextBase httpContext) { IserviceAdmin spa = new serviceAdmin(); IPrincipal user = httpContext.User; bool authorize = false; string userid = user.Identity.Name; Admin _admin = spa.Get(x => x.username == userid); if (_admin != null && Roles.Contains(_admin.type)) { authorize = true; } return(authorize); }