diff --git a/SeniorAssistant/Controllers/AccountController.cs b/SeniorAssistant/Controllers/AccountController.cs index 744ab7a..d33ac8b 100644 --- a/SeniorAssistant/Controllers/AccountController.cs +++ b/SeniorAssistant/Controllers/AccountController.cs @@ -71,137 +71,14 @@ namespace IdentityDemo.Controllers return Json(new JsonResponse()); } + public ActionResult _register() + { + return Json(new JsonResponse()); + } internal class JsonResponse { public bool Success { get; internal set; } public string Message { get; internal set; } } - /* - [HttpPost] - [AllowAnonymous] - [ValidateAntiForgeryToken] - public async Task Login(LoginViewModel model, string returnUrl = null) - { - ViewData["ReturnUrl"] = returnUrl; - if (ModelState.IsValid) - { - // This doesn't count login failures towards account lockout - // To enable password failures to trigger account lockout, set lockoutOnFailure: true - var result = await _signInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: false); - if (result.Succeeded) - { - _logger.LogInformation("User logged in."); - return RedirectToLocal(returnUrl); - } - if (result.IsLockedOut) - { - _logger.LogWarning("User account locked out."); - return RedirectToAction(nameof(Lockout)); - } - else - { - ModelState.AddModelError(string.Empty, "Invalid login attempt."); - return View(model); - } - } - - // If we got this far, something failed, redisplay form - return View(model); - } - - [HttpGet] - [AllowAnonymous] - public IActionResult Lockout() - { - return View(); - } - - [HttpGet] - [AllowAnonymous] - public IActionResult Register(string returnUrl = null) - { - ViewData["ReturnUrl"] = returnUrl; - return View(); - } - - [HttpPost] - [AllowAnonymous] - [ValidateAntiForgeryToken] - public async Task Register(RegisterViewModel model, string returnUrl = null) - { - ViewData["ReturnUrl"] = returnUrl; - if (ModelState.IsValid) - { - var user = new User { UserName = model.Email, Email = model.Email }; - var result = await _userManager.CreateAsync(user, model.Password); - if (result.Succeeded) - { - await _signInManager.SignInAsync(user, isPersistent: false); - _logger.LogInformation("User created a new account with password."); - return RedirectToLocal(returnUrl); - } - AddErrors(result); - } - - // If we got this far, something failed, redisplay form - return View(model); - } - - [HttpPost] - [ValidateAntiForgeryToken] - public async Task Logout() - { - await _signInManager.SignOutAsync(); - _logger.LogInformation("User logged out."); - return RedirectToAction(nameof(HomeController.Index), "Home"); - } - - [HttpGet] - [AllowAnonymous] - public async Task ConfirmEmail(string userId, string code) - { - if (userId == null || code == null) - { - return RedirectToAction(nameof(HomeController.Index), "Home"); - } - var user = await _userManager.FindByIdAsync(userId); - if (user == null) - { - throw new ApplicationException($"Unable to load user with ID '{userId}'."); - } - var result = await _userManager.ConfirmEmailAsync(user, code); - return View(result.Succeeded ? "ConfirmEmail" : "Error"); - } - - [HttpGet] - public IActionResult AccessDenied() - { - return View(); - } - - #region Helpers - - private void AddErrors(IdentityResult result) - { - foreach (var error in result.Errors) - { - ModelState.AddModelError(string.Empty, error.Description); - } - } - - private IActionResult RedirectToLocal(string returnUrl) - { - if (Url.IsLocalUrl(returnUrl)) - { - return Redirect(returnUrl); - } - else - { - return RedirectToAction(nameof(HomeController.Index), "Home"); - } - } - - #endregion - */ } } \ No newline at end of file diff --git a/SeniorAssistant/Controllers/HomeController.cs b/SeniorAssistant/Controllers/HomeController.cs index 56a2439..4ee48c6 100644 --- a/SeniorAssistant/Controllers/HomeController.cs +++ b/SeniorAssistant/Controllers/HomeController.cs @@ -38,10 +38,16 @@ namespace SeniorAssistant.Controllers return View(); } + [Route("Users")] + public IActionResult Users() + { + return View(); + } + [Route("User/{User}")] public IActionResult SingleUser(string user) { - return View("user", user); + return View("data", user); } } } \ No newline at end of file diff --git a/SeniorAssistant/Views/Home/User.cshtml b/SeniorAssistant/Views/Home/Data.cshtml similarity index 100% rename from SeniorAssistant/Views/Home/User.cshtml rename to SeniorAssistant/Views/Home/Data.cshtml diff --git a/SeniorAssistant/Views/Home/Index.cshtml b/SeniorAssistant/Views/Home/Index.cshtml index 4c30ece..8733407 100644 --- a/SeniorAssistant/Views/Home/Index.cshtml +++ b/SeniorAssistant/Views/Home/Index.cshtml @@ -1,53 +1,10 @@ -@model IEnumerable -@{ - ViewBag.Title = "Hello Razor"; -} - -
- - \ No newline at end of file + +

+ ciao noob +

\ No newline at end of file diff --git a/SeniorAssistant/Views/Home/Users.cshtml b/SeniorAssistant/Views/Home/Users.cshtml new file mode 100644 index 0000000..4c30ece --- /dev/null +++ b/SeniorAssistant/Views/Home/Users.cshtml @@ -0,0 +1,53 @@ +@model IEnumerable +@{ + ViewBag.Title = "Hello Razor"; +} + +
+ + \ No newline at end of file diff --git a/SeniorAssistant/Views/Shared/Login.cshtml b/SeniorAssistant/Views/Shared/Login.cshtml index d61cf90..ca1aefd 100644 --- a/SeniorAssistant/Views/Shared/Login.cshtml +++ b/SeniorAssistant/Views/Shared/Login.cshtml @@ -1,9 +1,18 @@ -
- - - - -
+ + + + + + \ No newline at end of file + diff --git a/SeniorAssistant/Views/Shared/Logout.cshtml b/SeniorAssistant/Views/Shared/Logout.cshtml index 30351db..a8c161e 100644 --- a/SeniorAssistant/Views/Shared/Logout.cshtml +++ b/SeniorAssistant/Views/Shared/Logout.cshtml @@ -1,6 +1,44 @@ -
- -
+@model string + + + User Image + + + + \ No newline at end of file diff --git a/SeniorAssistant/Views/Shared/Register.cshtml.cs b/SeniorAssistant/Views/Shared/Register.cshtml.cs new file mode 100644 index 0000000..c7f3879 --- /dev/null +++ b/SeniorAssistant/Views/Shared/Register.cshtml.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; + +namespace SeniorAssistant.Views.Shared +{ + public class RegisterModel : PageModel + { + public void OnGet() + { + } + } +} \ No newline at end of file diff --git a/SeniorAssistant/senior.db b/SeniorAssistant/senior.db index b3d5cc5..7a77058 100644 Binary files a/SeniorAssistant/senior.db and b/SeniorAssistant/senior.db differ