Exemplo n.º 1
0
        public PartialViewResult GetRequestView()
        {
            UserPrincipal userPrincipal = (UserPrincipal)User;
            UserDetails   userDetails   = this.userManager.GetUserDetailsByAccessToken(userPrincipal.AccessToken);
            //// string userId = this.userManager.GetUserIdByName(userPrincipal.UserName).ToString();
            string userId = userDetails.UserInfo.RowKey;
            AccessElevationViewModel viewModel = new AccessElevationViewModel()
            {
                UserId = userId
            };

            return(this.PartialView("ElivatedAccessPartial", viewModel));
        }
Exemplo n.º 2
0
        public ActionResult RequestElevatedAccess(AccessElevationViewModel elevationModel)
        {
            var           userDetails        = this.userManager.GetUserAndAccessDetailsByUserId(elevationModel.UserId);
            AccessDetails currentAccessLevel = userDetails.AccessInfo.Where(x => x.Authority.ToString() == elevationModel.Regulatory).FirstOrDefault();

            if (ModelState.IsValid)
            {
                if (this.AnyRequestPending(elevationModel.UserId, elevationModel.Regulatory))
                {
                    ViewBag.Message = "Request is pending for access elevation";
                }
                else
                {
                    AccessElevationRequest requestAccess = new AccessElevationRequest
                    {
                        PartitionKey         = elevationModel.UserId,
                        Regulatory           = elevationModel.Regulatory,
                        CurrentAccessLevel   = Convert.ToInt32(currentAccessLevel.AccessLevel),
                        RequestedAccessLevel = Convert.ToInt32(elevationModel.AccessRole),
                        Justification        = elevationModel.Justification,
                        RequestStatus        = (int)RequestStatus.Pending
                    };

                    this.userManager.RequestAccessElevation(requestAccess);

                    this.ProfileAuditor.UserId        = elevationModel.UserId;
                    this.ProfileAuditor.TransactionId = this.ProfileLogger.TransactionId;
                    this.ProfileAuditor.Audit(AuditId.RequestAccessElevation, AuditStatus.Success, default(int), userDetails.UserInfo.UserName + " requested access elevation");
                    this.ProfileLogger.Log(TraceEventType.Information, LoggingMessageId.PortalUserAccessLevelElevationRequest, userDetails.UserInfo.UserName + " requested access elevation");

                    ViewBag.Message = "Request Submitted Successfully";
                }
            }

            AccessElevationViewModel viewModel = new AccessElevationViewModel()
            {
                UserId = elevationModel.UserId
            };

            if (currentAccessLevel != null)
            {
                viewModel.Roles = Utility.GetUpgradableAccessLevels(Convert.ToInt32(currentAccessLevel.AccessLevel), elevationModel.Regulatory.ToLower());
            }

            return(this.PartialView("ElivatedAccessPartial", viewModel));
        }