39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Configuration;
|
|
using System;
|
|
using System.Net.Http;
|
|
|
|
namespace GanjooRazor.Pages
|
|
{
|
|
[IgnoreAntiforgeryToken(Order = 1001)]
|
|
public class LoginModel : LoginPartialEnabledPageModel
|
|
{
|
|
|
|
public LoginModel(HttpClient httpClient, IConfiguration configuration) : base(httpClient, configuration) { }
|
|
public string UserFriendlyName { get; set; }
|
|
|
|
public string LastError { get; set; }
|
|
|
|
public string RedirectUrl { get; set; }
|
|
|
|
/// <summary>
|
|
/// <see cref="RedirectUrl"/>, URL-encoded for embedding directly in the login form's
|
|
/// action attribute
|
|
/// </summary>
|
|
public string RedirectUrlEncoded => Uri.EscapeDataString(RedirectUrl);
|
|
|
|
public void OnGet()
|
|
{
|
|
UserFriendlyName = Request.Cookies["Name"];
|
|
LoggedIn = !string.IsNullOrEmpty(UserFriendlyName);
|
|
LastError = Request.Query["error"];
|
|
RedirectUrl = Request.Query["redirect"];
|
|
if (string.IsNullOrEmpty(RedirectUrl))
|
|
{
|
|
RedirectUrl = "/";
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|