public string RolersGrantsUpdate(GrantsModifyReq req) { GrantsModifyRes res = new GrantsModifyRes(); if (Session["ID"] == null) { res.ReturnStatus = new ReturnStatus(ReturnCode.SESSION_TIMEOUT); } else { try { Log("Req=" + JsonConvert.SerializeObject(req)); req.CUSER = Session["ID"].ToString(); req.MUSER = Session["ID"].ToString(); int i = new Grants("SCC").ByRolesUpdate(req); res.ReturnStatus = new ReturnStatus(ReturnCode.SET_SUCCESS); } catch (Exception ex) { Log("Err=" + ex.Message); Log(ex.StackTrace); res.ReturnStatus = new ReturnStatus(ReturnCode.SERIOUS_ERROR); } } var json = JsonConvert.SerializeObject(res); Log("Res=" + json); return(json); }
private HttpResponseMessage ProcessAuthorizationCodeRequest(ValidatedRequest validatedRequest) { Tracing.Information("Processing authorization code request"); var tokenService = new OidcTokenService( ServerConfiguration.Global.IssuerUri, ServerConfiguration.Keys.SigningCertificate); var response = tokenService.CreateTokenResponse(validatedRequest.Grant, validatedRequest.Client.AccessTokenLifetime); Grants.Delete(validatedRequest.Grant.GrantId); if (validatedRequest.Grant.Scopes.Contains(OidcConstants.Scopes.OfflineAccess) && validatedRequest.Client.AllowRefreshToken) { var refreshToken = StoredGrant.CreateRefreshToken( validatedRequest.Grant.ClientId, validatedRequest.Grant.Subject, validatedRequest.Grant.Scopes, validatedRequest.Client.RefreshTokenLifetime); Grants.Add(refreshToken); response.RefreshToken = refreshToken.GrantId; } return(Request.CreateTokenResponse(response)); }
/// <summary> /// Check User (for compability with a Discord) user Grants and Run Cmd /// </summary> /// <param name="login"></param> /// <param name="cmd"></param> /// <returns></returns> public static ModelStatus TryGetCmdForUser(string login, Grants grants, string command, out IChatCmd result) { result = null; if (ChatManager.ChatCmds.TryGetValue(command, out IChatCmd cmd)) { if (((int)cmd.GrantsForRun & (int)grants) > 0) { result = cmd; return(new ModelStatus() { Status = 0, Message = string.Empty }); } else { return(new ModelStatus() { Status = (int)ChatCmdResult.AccessDeny, Message = $"user {login} does not have permission for run " + command, }); } } return(new ModelStatus() { Status = (int)ChatCmdResult.CommandNotFound, Message = "Command not found: " + command }); }
/// <summary> /// Dependent type names of this entity /// </summary> public void DeleteChildren(DatabaseEntities dbContext) { foreach (var x in Grants.ToList()) { x.DeleteFull(dbContext); } }
public async Task <IActionResult> OnGetAsync(Guid?id) { if (id == null) { return(NotFound()); } Session = await _context.RtcSessions .Include(session => session.Creator) .FirstOrDefaultAsync(m => m.Id == id); if (Session == null) { return(NotFound()); } var user = await _userManager.GetUserAsync(User); // get active invite ActiveInvite = await _inviteService.GetActiveAsync(Session.Id, user.Id); // get all grants (members) Grants = await _context.RtcSessionGrants .OrderByDescending(grant => grant.CreationTime) .Where(grant => grant.Session.Id == Session.Id) .Include(grant => grant.User) .ToListAsync(); Joined = Grants.Any(grant => grant.User == user); return(Page()); }
/// <summary> /// Creates a S3Grant and adds it to the list of grants. /// </summary> /// <param name="grantee">The grantee for the grant.</param> /// <param name="permission">The permission for the grantee.</param> public void AddGrant(S3Grantee grantee, S3Permission permission) { S3Grant grant = new S3Grant(); grant.WithGrantee(grantee); grant.WithPermission(permission); Grants.Add(grant); }
/// <summary> /// Creates a S3Grant and adds it to the list of grants. /// </summary> /// <param name="grantee">The grantee for the grant.</param> /// <param name="permission">The permission for the grantee.</param> public void AddGrant(S3Grantee grantee, S3Permission permission) { S3Grant grant = new S3Grant { Grantee = grantee, Permission = permission }; Grants.Add(grant); }
public ActionResult DeleteConfirmed(int id) { Grants grants = db.Grants.Find(id); db.Grants.Remove(grants); db.SaveChanges(); TempData["msg"] = "<script>alert('This grant record has been successfuly deleted.')</script>"; return(RedirectToAction("Index", "PostGraduation", new { id = grants.StudentID })); }
public void AddGrant(S3Grantee grantee, S3Permission permission) { S3Grant item = new S3Grant { Grantee = grantee, Permission = permission }; Grants.Add(item); }
/// <summary> /// Active Dependent type names of this object /// </summary> public List <string> DependentObjectNames() { var dependentObjects = new List <string>(); if (Grants.Any()) { dependentObjects.Add(typeof(Grant).Name); } return(dependentObjects.Distinct().ToList()); }
/// <summary> /// Check if a user may do something - and throw an error if the permission is not given /// </summary> internal void PerformSecurityCheck(int appId, string contentType, Grants grant, ModuleInfo module, App app, IEntity specificItem = null) => new Security(PortalSettings, Log).FindCtCheckSecurityOrThrow(appId, contentType, new List <Grants> { grant }, specificItem, module, app);
/// <summary> /// Active Dependent type names of this object /// </summary> public List <string> DependentObjectNames() { var dependentObjects = new List <string>(); if (Agreements.Any()) { dependentObjects.Add(typeof(Agreement).Name); } if (GisUploadSourceOrganizationsWhereYouAreTheDefaultLeadImplementerOrganization.Any()) { dependentObjects.Add(typeof(GisUploadSourceOrganization).Name); } if (Grants.Any()) { dependentObjects.Add(typeof(Grant).Name); } if (GrantAllocations.Any()) { dependentObjects.Add(typeof(GrantAllocation).Name); } if (OrganizationBoundaryStagings.Any()) { dependentObjects.Add(typeof(OrganizationBoundaryStaging).Name); } if (People.Any()) { dependentObjects.Add(typeof(Person).Name); } if (PersonStewardOrganizations.Any()) { dependentObjects.Add(typeof(PersonStewardOrganization).Name); } if (Programs.Any()) { dependentObjects.Add(typeof(Program).Name); } if (ProjectOrganizations.Any()) { dependentObjects.Add(typeof(ProjectOrganization).Name); } if (ProjectOrganizationUpdates.Any()) { dependentObjects.Add(typeof(ProjectOrganizationUpdate).Name); } return(dependentObjects.Distinct().ToList()); }
/// <summary> /// Removes a specific permission for the given grantee. /// </summary> /// <param name="grantee">The grantee</param> /// <param name="permission">The permission for the grantee to remove</param> public void RemoveGrant(S3Grantee grantee, S3Permission permission) { foreach (S3Grant grant in Grants) { if (grant.Grantee.Equals(grantee) && grant.Permission == permission) { Grants.Remove(grant); break; } } }
/// <summary> /// Dependent type names of this entity /// </summary> public void DeleteChildren(DatabaseEntities dbContext) { foreach (var x in Agreements.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GisUploadSourceOrganizationsWhereYouAreTheDefaultLeadImplementerOrganization.ToList()) { x.DeleteFull(dbContext); } foreach (var x in Grants.ToList()) { x.DeleteFull(dbContext); } foreach (var x in GrantAllocations.ToList()) { x.DeleteFull(dbContext); } foreach (var x in OrganizationBoundaryStagings.ToList()) { x.DeleteFull(dbContext); } foreach (var x in People.ToList()) { x.DeleteFull(dbContext); } foreach (var x in PersonStewardOrganizations.ToList()) { x.DeleteFull(dbContext); } foreach (var x in Programs.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectOrganizations.ToList()) { x.DeleteFull(dbContext); } foreach (var x in ProjectOrganizationUpdates.ToList()) { x.DeleteFull(dbContext); } }
public ActionResult Edit([Bind(Include = "ID,StudentID,GrantInformation,GrantMonthId,GrantYear")] Grants grants) { if (ModelState.IsValid) { db.Entry(grants).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "PostGraduation", new { id = grants.StudentID })); } ViewBag.GrantMonthId = new SelectList(db.CommonFields.Where(o => o.Category == "Months"), "ID", "Name", grants.GrantMonthId); ViewBag.Student = grants.Student; ViewBag.StudentID = grants.StudentID; return(View(grants)); }
// GET: Grants/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Grants grants = db.Grants.Find(id); if (grants == null) { return(HttpNotFound()); } return(View(grants)); }
public void RemoveGrant(S3Grantee grantee) { List <S3Grant> list = new List <S3Grant>(); foreach (S3Grant grant in Grants) { if (grant.Grantee.Equals(grantee)) { list.Add(grant); } } foreach (S3Grant item in list) { Grants.Remove(item); } }
// GET: Grants/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Grants grants = db.Grants.Find(id); if (grants == null) { return(HttpNotFound()); } ViewBag.GrantMonthId = new SelectList(db.CommonFields.Where(o => o.Category == "Months"), "ID", "Name", grants.GrantMonthId); ViewBag.Student = grants.Student; ViewBag.StudentID = grants.StudentID; return(View(grants)); }
// GET: Grants/Delete/5 public ActionResult Delete(int?id) { if (id == null) { TempData["msg"] = "<script>alert('Sorry! NO record found to delete.')</script>"; return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Grants grants = db.Grants.Find(id); if (grants == null) { TempData["msg"] = "<script>alert('Sorry! No record found to delete.')</script>"; return(HttpNotFound()); } int sendId = (int)id; return(DeleteConfirmed(sendId)); }
public PermChecker(NodeInfo checkThis, List <Perm> perms) { Seeking = checkThis; foreach (var p in perms) { if (p.Type == PermType.Allow) { Allows.Add(p); } else if (p.Type == PermType.Deny) { Denies.Add(p); } else { Grants.Add(p); } } }
public List <Grants> GetGrantRequest(int Person) { //this method returns all grants var Grants = from b in db.GrantRequests select b; List <Grants> grants = new List <Grants>(); foreach (Grants gr in grants) { Grants grant1 = new Grants(); grant1.GrantRequestDate = gr.GrantRequestDate; grant1.PersonKey = gr.PersonKey; grant1.GrantTypeKey = gr.GrantTypeKey; grant1.GrantRequestExplanation = gr.GrantRequestExplanation; grant1.GrantRequestAmount = gr.GrantRequestAmount; //add to the list of grants grants.Add(grant1); } return(grants); }
public ActionResult Post([FromBody] Grants grants) { _unitOfWork.GrantRepository.Insert(grants); _unitOfWork.Save(); return(Ok()); }
/// <summary> /// Does this object have any dependent objects? (If it does have dependent objects, these would need to be deleted before this object could be deleted.) /// </summary> /// <returns></returns> public bool HasDependentObjects() { return(Grants.Any()); }
/// <summary> /// Does this object have any dependent objects? (If it does have dependent objects, these would need to be deleted before this object could be deleted.) /// </summary> /// <returns></returns> public bool HasDependentObjects() { return(Agreements.Any() || GisUploadSourceOrganizationsWhereYouAreTheDefaultLeadImplementerOrganization.Any() || Grants.Any() || GrantAllocations.Any() || OrganizationBoundaryStagings.Any() || People.Any() || PersonStewardOrganizations.Any() || Programs.Any() || ProjectOrganizations.Any() || ProjectOrganizationUpdates.Any()); }
public ModelStatus Execute(ref PlayerServer player, Chat chat, List <string> argsM) { var myLogin = player.Public.Login; if (argsM.Count < 1) { return(_chatManager.PostCommandPrivatPostActivChat(ChatCmdResult.CommandNotFound, myLogin, chat, Help)); } var subCmd = argsM[0]?.ToLower(); if (argsM.Count < 2) { return(_chatManager.PostCommandPrivatPostActivChat(ChatCmdResult.PlayerNameEmpty, myLogin, chat, "Player name is empty")); } var anotherPlayer = Repository.GetPlayerByLogin(argsM[1]); if (anotherPlayer == null) { return(_chatManager.PostCommandPrivatPostActivChat(ChatCmdResult.UserNotFound, myLogin, chat, $"Player {argsM[1]} not found :-(")); } Grants newGrants = Grants.NoPermissions; if ("add".Equals(subCmd) || "revoke".Equals(subCmd)) { if (argsM.Count < 3) { return(_chatManager.PostCommandPrivatPostActivChat(ChatCmdResult.IncorrectSubCmd, myLogin, chat, $"role can be empty")); } newGrants = GetGrantsByStr(argsM[2]); if (newGrants.Equals(Grants.NoPermissions)) { return(_chatManager.PostCommandPrivatPostActivChat(ChatCmdResult.RoleNotFound, myLogin, chat, $"retype role, this {argsM[2]} not found")); } } // anotherPlayer может стать null ? switch (subCmd) { case "add": { var msg = $"User {myLogin} add grants {newGrants.ToString()} to {anotherPlayer.Public.Login}"; Loger.Log(msg); lock (anotherPlayer.Public) { anotherPlayer.Public.Grants = anotherPlayer.Public.Grants | newGrants; } Repository.Get.ChangeData = true; return(new ModelStatus() { Status = 0, Message = msg, }); } case "revoke": { var msg = $"User {myLogin} revoke grants {newGrants.ToString()} from {anotherPlayer.Public.Login}"; Loger.Log(msg); lock (anotherPlayer.Public) { anotherPlayer.Public.Grants = anotherPlayer.Public.Grants & ~newGrants; } Repository.Get.ChangeData = true; return(new ModelStatus() { Status = 0, Message = msg, }); } case "type": { return(_chatManager.PostCommandPrivatPostActivChat(0, myLogin, chat, $"User {anotherPlayer.Public.Login} have:" + anotherPlayer.Public.Grants.ToString())); } default: { return(_chatManager.PostCommandPrivatPostActivChat(ChatCmdResult.CommandNotFound, myLogin, chat, $"cmd '/grants {argsM[0]}' not found")); } } }