Full rewrite of the portfolio site from Next.js 14 to .NET 10: - ASP.NET Core 10 Razor Pages, no Node.js dependency - EF Core 10 + SQLite (same schema as before — data survives upgrade) - Cookie authentication (same single-password model) - Resend contact form via HttpClient - Bilingual FA/EN via locale cookie + BasePageModel - All UI ported to Razor Pages with Tailwind CDN + custom CSS - Vanilla JS: particles, typewriter, cursor, animations, portfolio modal - Dockerfile: SDK 10.0-alpine → aspnet 10.0-alpine (no npm/Node needed) - CI/CD: dropped NPM_TOKEN, ADMIN_SESSION_SECRET — pure dotnet publish Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using SoroushAsadi.Services;
|
||||
|
||||
namespace SoroushAsadi.Pages.Admin;
|
||||
|
||||
public class LoginModel(AuthService auth) : PageModel
|
||||
{
|
||||
public string Error { get; private set; } = "";
|
||||
|
||||
public void OnGet() { }
|
||||
|
||||
public async Task<IActionResult> OnPostAsync(string password, string returnUrl = "/Admin")
|
||||
{
|
||||
if (!auth.VerifyPassword(password))
|
||||
{
|
||||
Error = "Incorrect password.";
|
||||
return Page();
|
||||
}
|
||||
|
||||
var claims = new[] { new Claim(ClaimTypes.Name, "admin") };
|
||||
var identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
await HttpContext.SignInAsync(
|
||||
CookieAuthenticationDefaults.AuthenticationScheme,
|
||||
new ClaimsPrincipal(identity));
|
||||
|
||||
if (!Url.IsLocalUrl(returnUrl)) returnUrl = "/Admin";
|
||||
return LocalRedirect(returnUrl);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user