public async Task <ActionResult> About() { var myGroups = new List <Group>(); var myDirectoryRoles = new List <DirectoryRole>(); try { ClaimsIdentity claimsId = ClaimsPrincipal.Current.Identity as ClaimsIdentity; List <string> objectIds = await ClaimHelper.GetGroups(claimsId); await GraphHelper.GetDirectoryObjects(objectIds, myGroups, myDirectoryRoles); } catch (AdalException e) { // If the user doesn't have an access token, they need to re-authorize if (e.ErrorCode == "failed_to_acquire_token_silently") { return(RedirectToAction("Reauth", "Error", new { redirectUri = Request.Url })); } return(RedirectToAction("ShowError", "Error", new { errorMessage = "Error while acquiring token." })); } catch (Exception e) { return(RedirectToAction("ShowError", "Error", new { errorMessage = e.Message })); } ViewData["myGroups"] = myGroups; ViewData["myDirectoryRoles"] = myDirectoryRoles; ViewData["overageOccurred"] = (ClaimsPrincipal.Current.FindFirst("_claim_names") != null && (System.Web.Helpers.Json.Decode(ClaimsPrincipal.Current.FindFirst("_claim_names").Value)).groups != null); 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)); }
// GET api/values public async Task <IEnumerable <string> > Get() { var myGroups = new List <Group>(); var myDirectoryRoles = new List <DirectoryRole>(); ClaimsIdentity claimsId = ClaimsPrincipal.Current.Identity as ClaimsIdentity; var objectIds = await ClaimHelper.GetGroups(claimsId); await GraphHelper.GetDirectoryObjects(objectIds, myGroups, myDirectoryRoles); return(myGroups.Select(d => d.DisplayName)); }
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()); }
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 })); } }