using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Graph;
using Microsoft.Identity.Web;

[AuthorizeForScopes(Scopes = new[] { "user.read" })]

public class HomeController : Controller
{
    private readonly GraphServiceClient _graphServiceClient;

    public HomeController(GraphServiceClient graphServiceClient)
    {
        _graphServiceClient = graphServiceClient;
    }

    public async Task<IActionResult> Index()
    {
        var user = await _graphServiceClient.Me.Request().GetAsync();
        return View(user);
    }
}

// public class HomeController : Controller
// {
//     private readonly ITokenAcquisition _tokenAcquisition;
//     private readonly GraphServiceClient _graphServiceClient;

//     public HomeController(ITokenAcquisition tokenAcquisition, GraphServiceClient graphServiceClient)
//     {
//         _tokenAcquisition = tokenAcquisition;
//         _graphServiceClient = graphServiceClient;
//     }

//     public async Task<IActionResult> Index()
//     {
//         var user = await _graphServiceClient.Me.Request().GetAsync();
//         return View(user);
//     }

//     [Authorize(Policy = "AdminOnly")]
//     public IActionResult AdminDashboard()
//     {
//         return View();
//     }
// }
