generated from egmont11/ASP.Net-Core-MVC-Template
Odstranění zbytečných stránek, přidání administrace pro pozvánky.
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -11,11 +11,6 @@ public class HomeController : Controller
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user