public async Task<IActionResult> Index()
        {
            // This is how group ids/names are used in the IsInRole method
            // var isinrole = User.IsInRole("8873daa2-17af-4e72-973e-930c94ef7549");

            string accessToken = await tokenAcquisition.GetAccessTokenForUserAsync(new[] { Constants.ScopeUserRead, Constants.ScopeDirectoryReadAll });

            User me = await graphService.GetMeAsync(accessToken);
            ViewData["Me"] = me;

            try
            {
                var photo = await graphService.GetMyPhotoAsync(accessToken);
                ViewData["Photo"] = photo;
            }
            catch
            {
                //swallow
            }
            
            IList<Group> groups = await graphService.GetMyMemberOfGroupsAsync(accessToken);            
            ViewData["Groups"] = groups;

            return View();
        }
        public async Task <IActionResult> Index()
        {
            // Using group ids/names in the IsInRole method
            var isinrole = User.IsInRole("d206a687-949c-481d-92ab-710ed5b66845");

            string accessToken = await tokenAcquisition.GetAccessTokenForUserAsync(new[] { Constants.ScopeUserRead, Constants.ScopeDirectoryReadAll });

            User me = await graphService.GetMeAsync(accessToken);

            ViewData["Me"] = me;

            try
            {
                var photo = await graphService.GetMyPhotoAsync(accessToken);

                ViewData["Photo"] = photo;
            }
            catch
            {
                //swallow
            }

            IList <Group> groups = await graphService.GetMyMemberOfGroupsAsync(accessToken);

            ViewData["Groups"] = groups;

            return(View());
        }
        public async Task <IActionResult> Index()
        {
            // Using group ids/names in the IsInRole method
            // var isinrole = User.IsInRole("a9cccbf0-6fb5-41ec-a45b-e76e57fd241a");

            ViewData["User"] = HttpContext.User;

            string accessToken = await tokenAcquisition.GetAccessTokenOnBehalfOfUserAsync(new[] { Constants.ScopeUserRead, Constants.ScopeDirectoryReadAll });

            User me = await graphService.GetMeAsync(accessToken);

            ViewData["Me"] = me;

            try
            {
                var photo = await graphService.GetMyPhotoAsync(accessToken);

                ViewData["Photo"] = photo;
            }
            catch
            {
                //swallow
            }

            IList <Group> groups = await graphService.GetMyMemberOfGroupsAsync(accessToken);

            ViewData["Groups"] = groups;

            return(View());
        }
        public async Task <IActionResult> Index()
        {
            string accessToken = await tokenAcquisition.GetAccessTokenOnBehalfOfUser(HttpContext, new[] { Constants.ScopeUserRead, Constants.ScopeDirectoryReadAll });

            User me = await graphService.GetMeAsync(accessToken);

            var photo = await graphService.GetMyPhotoAsync(accessToken);

            IList <Group> groups = await graphService.GetMyMemberOfGroupsAsync(accessToken);

            ViewData["Me"]     = me;
            ViewData["Photo"]  = photo;
            ViewData["Groups"] = groups;

            return(View());
        }
Esempio n. 5
0
        public async Task <IActionResult> Profile()
        {
            string token = await _tokenAcquisition.GetAccessTokenForUserAsync(new[] { Infrastructure.Constants.ScopeUserRead, Infrastructure.Constants.ScopeDirectoryReadAll });

            User me = await _graphService.GetMeAsync(token);

            ViewData["Me"] = me;

            try
            {
                // Get user photo
                ViewData["Photo"] = await _graphService.GetMyPhotoAsync(token);
            }
            catch (System.Exception)
            {
                ViewData["Photo"] = null;
            }

            IList <Group> groups = await _graphService.GetMyMemberOfGroupsAsync(token);

            ViewData["Groups"] = groups;

            return(View());
        }