public async Task <ActionResult> Share(string id) { AuthenticationHelper authHelper = new AuthenticationHelper(ConfigHelper.Authority, new ADALTokenCache(Util.GetSignedInUsersObjectIdFromClaims())); // Values Needed for the People Picker ViewData["tenant"] = ConfigHelper.TenantId; ViewData["token"] = await authHelper.GetOnBehalfOfAccessToken(ConfigHelper.GraphResourceId, ConfigHelper.PostLogoutRedirectUri); UserGroupsAndDirectoryRoles userGroupsAndDirectoryRoles = await TokenHelper.GetUsersGroupsAsync(ClaimsPrincipal.Current); List <string> userGroupsAndId = userGroupsAndDirectoryRoles.GroupIds; string userObjectId = Util.GetSignedInUsersObjectIdFromClaims(); userGroupsAndId.Add(userObjectId); ViewData["tasks"] = TasksDbHelper.GetAllTasks(userGroupsAndId); ViewData["userId"] = userObjectId; // Get the task details WebApp_GroupClaims_DotNet.Models.Task task = TasksDbHelper.GetTask(Convert.ToInt32(id)); if (task == null) { RedirectToAction("ShowError", "Error", new { message = "Task Not Found in DB." }); } ViewData["shares"] = task.SharedWith.ToList(); ViewData["taskText"] = task.TaskText; ViewData["taskId"] = task.TaskID; return(View()); }
private void EnsureOwnerOfTask(int taskId) { // Check if the user is the owner of the task Models.Task task = TasksDbHelper.GetTask(taskId); string userObjectId = ClaimsPrincipal.Current.FindFirst(Globals.ObjectIdClaimType).Value; if (task.Creator != userObjectId) { throw new HttpResponseException(HttpStatusCode.Forbidden); } }
public List <Models.Share> GetShares(int id) { Models.Task task = TasksDbHelper.GetTask(id); List <Models.Share> shares = new List <Models.Share>(); foreach (Models.AadObject share in task.SharedWith) { if (share.AadObjectID != ClaimsPrincipal.Current.FindFirst(Globals.ObjectIdClaimType).Value) { shares.Add(new Models.Share { objectID = share.AadObjectID, displayName = share.DisplayName }); } } return(shares); }
public ActionResult Share(string id) { // Values Needed for the People Picker ViewData["tenant"] = ConfigHelper.Tenant; ViewData["token"] = GraphHelper.AcquireToken(ClaimsPrincipal.Current.FindFirst(Globals.ObjectIdClaimType).Value); // Get the task details WebAppGroupClaimsDotNet.Models.Task task = TasksDbHelper.GetTask(Convert.ToInt32(id)); if (task == null) { RedirectToAction("ShowError", "Error", new { message = "Task Not Found in DB." }); } ViewData["shares"] = task.SharedWith.ToList(); ViewData["taskText"] = task.TaskText; ViewData["taskId"] = task.TaskID; ViewData["userId"] = ClaimsPrincipal.Current.FindFirst(Globals.ObjectIdClaimType).Value; return(View()); }
public List <Models.Share> GetShares(int id) { // Read the list of shares for the task EnsureAccessToTask(id); Models.Task task = TasksDbHelper.GetTask(id); List <Models.Share> shares = new List <Models.Share>(); foreach (Models.AadObject share in task.SharedWith) { // Don't show the client that the task is shared with the owner if (share.AadObjectID != ClaimsPrincipal.Current.FindFirst(Globals.ObjectIdClaimType).Value) { shares.Add(new Models.Share { objectId = share.AadObjectID, displayName = share.DisplayName }); } } return(shares); }
public Models.Task Get(int id) { EnsureAccessToTask(id); return(TasksDbHelper.GetTask(id)); }
public Models.Task Get(int id) { List <object> tasks = new List <object>(); return(TasksDbHelper.GetTask(id)); }