Odstranění zbytečných stránek, přidání administrace pro pozvánky.

This commit is contained in:
Matěj Kubíček
2026-09-17 17:06:27 +02:00
parent 2040a16879
commit 3a35d10227
11 changed files with 136 additions and 121 deletions
@@ -36,16 +36,6 @@ public class AuthController : Controller
return View(new AuthLoginViewModel { ReturnUrl = returnUrl });
}
[HttpGet]
[AllowAnonymous]
public IActionResult Register(string? returnUrl)
{
if (User.Identity?.IsAuthenticated == true)
return RedirectToAction("Index", "Home");
return View(new AuthRegisterViewModel { ReturnUrl = returnUrl });
}
[HttpGet]
public IActionResult AccessDenied() => View();
@@ -100,36 +90,6 @@ public class AuthController : Controller
return RedirectToAction("Index", "Home");
}
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Register(AuthRegisterViewModel model)
{
if (!ModelState.IsValid) return View(model);
var user = new UserEntity
{
UserName = model.UserName.Trim(),
Email = model.Email.Trim().ToLower(),
};
var result = await _userManager.CreateAsync(user, model.Password);
if (!result.Succeeded)
{
foreach (var error in result.Errors)
ModelState.AddModelError(string.Empty, error.Description);
return View(model);
}
await _userManager.AddToRoleAsync(user, "User");
_logger.LogInformation("User {UserName} registered.", user.UserName);
if (!string.IsNullOrEmpty(model.ReturnUrl) && Url.IsLocalUrl(model.ReturnUrl))
return Redirect(model.ReturnUrl);
return RedirectToAction("Login");
}
[HttpPost]
[Authorize]
[ValidateAntiForgeryToken]