using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace Nalu.Web.Pages;

public class LoginModel : PageModel
{
    public string? ReturnUrl { get; private set; }

    public void OnGet(string? returnUrl = null)
    {
        ReturnUrl = returnUrl ?? "/painel";
    }

    public IActionResult OnGetGoogle(string? returnUrl = null) =>
        Challenge(new Microsoft.AspNetCore.Authentication.AuthenticationProperties
        {
            RedirectUri = $"/auth/callback?returnUrl={Uri.EscapeDataString(returnUrl ?? "/painel")}"
        }, "Google");

    public IActionResult OnGetMicrosoft(string? returnUrl = null) =>
        Challenge(new Microsoft.AspNetCore.Authentication.AuthenticationProperties
        {
            RedirectUri = $"/auth/callback?returnUrl={Uri.EscapeDataString(returnUrl ?? "/painel")}"
        }, "Microsoft");

    public IActionResult OnGetGitHub(string? returnUrl = null) =>
        Challenge(new Microsoft.AspNetCore.Authentication.AuthenticationProperties
        {
            RedirectUri = $"/auth/callback?returnUrl={Uri.EscapeDataString(returnUrl ?? "/painel")}"
        }, "GitHub");
}
