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()); }
public List <Models.Task> GetAll() { string userObjectId = ClaimsPrincipal.Current.FindFirst(Globals.ObjectIdClaimType).Value; return(TasksDbHelper.GetAllTasks(new List <string> { userObjectId })); }
public async Task <ActionResult> Index() { string userObjectId = ClaimsPrincipal.Current.FindFirst(Globals.ObjectIdClaimType).Value; ViewData["userId"] = userObjectId; ViewData["tenant"] = ClaimsPrincipal.Current.FindFirst(Globals.TenantIdClaimType).Value; ViewData["tasks"] = TasksDbHelper.GetAllTasks(new List <string> { userObjectId }); return(View()); }
public async Task <List <Models.Task> > GetAll() { List <object> tasks = new List <object>(); ClaimsIdentity userClaimsId = ClaimsPrincipal.Current.Identity as ClaimsIdentity; List <string> userGroupsAndId = await ClaimHelper.GetGroups(userClaimsId); string userObjectId = userClaimsId.FindFirst(Globals.ObjectIdClaimType).Value; userGroupsAndId.Add(userObjectId); return(TasksDbHelper.GetAllTasks(userGroupsAndId)); }
public async Task <ActionResult> Index() { ClaimsIdentity userClaimsId = ClaimsPrincipal.Current.Identity as ClaimsIdentity; string userObjectId = userClaimsId.FindFirst(Globals.ObjectIdClaimType).Value; List <string> userGroupsAndId = await ClaimHelper.GetGroups(userClaimsId); userGroupsAndId.Add(userObjectId); ViewData["userId"] = userObjectId; ViewData["tenant"] = ClaimsPrincipal.Current.FindFirst(Globals.TenantIdClaimType).Value; ViewData["tasks"] = TasksDbHelper.GetAllTasks(userGroupsAndId); return(View()); }
private void EnsureAccessToTask(int taskId) { // Check if the user has permission to access the task string userObjectId = ClaimsPrincipal.Current.FindFirst(Globals.ObjectIdClaimType).Value; List <Models.Task> tasks = TasksDbHelper.GetAllTasks(new List <string> { userObjectId }); if (tasks.Where(t => t.TaskID == taskId).Count() == 0) { throw new HttpResponseException(HttpStatusCode.Forbidden); } }
public async Task <ActionResult> Index() { try { // Get All Tasks User Can View ClaimsIdentity userClaimsId = ClaimsPrincipal.Current.Identity as ClaimsIdentity; List <string> userGroupsAndId = await ClaimHelper.GetGroups(userClaimsId); string userObjectId = userClaimsId.FindFirst(Globals.ObjectIdClaimType).Value; userGroupsAndId.Add(userObjectId); ViewData["tasks"] = TasksDbHelper.GetAllTasks(userGroupsAndId); ViewData["userId"] = userObjectId; return(View()); } catch (Exception e) { // Catch Both ADAL Exceptions and Web Exceptions return(RedirectToAction("ShowError", "Error", new { errorMessage = e.Message })); } }
public async Task <ActionResult> Index() { try { // Get All Tasks User Can View ClaimsIdentity userClaimsId = ClaimsPrincipal.Current.Identity as ClaimsIdentity; 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; return(View()); } catch (Exception e) { // Catch Both ADAL Exceptions and Web Exceptions return(RedirectToAction("ShowError", "Error", new { errorMessage = e.Message })); } }
public ActionResult Index() { var bearerAccessToken = CreateBearerAccessToken(); if (string.IsNullOrWhiteSpace(bearerAccessToken)) { return(View()); } bool isSuccessResponseCode; var jsonText = SendRequestGetResponse("api/ToGoList", "GET", null, bearerAccessToken, out isSuccessResponseCode); var listOfTasks = new List <Models.Task>(); JArray jArray = JArray.Parse(jsonText); foreach (var item in jArray) { listOfTasks.Add(new Models.Task { TaskID = (int)item["ID"], TaskText = (string)item["Description"], Status = "Not Started" }); } ViewBag.Message = "Tasks"; if (isSuccessResponseCode == true) { ViewData["tasks"] = listOfTasks; } else { ViewData["tasks"] = TasksDbHelper.GetAllTasks(); } return(View()); }
public ActionResult Index() { ViewBag.Message = "Tasks"; ViewData["tasks"] = TasksDbHelper.GetAllTasks(); return(View()); }