From 2f80dcf9205caadb5dd957a6797995e36a2cabb5 Mon Sep 17 00:00:00 2001 From: dasha Date: Fri, 19 May 2023 15:49:30 +0400 Subject: [PATCH] =?UTF-8?q?=D1=80=D0=B5=D0=B4=D0=B0=D0=BA=D1=82=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HomeController.cs | 33 ++++++++++++++++++- .../Views/Home/Privacy.cshtml | 29 ++++++++++++++++ .../Controllers/HomeController.cs | 4 +-- .../Views/Home/Builds.cshtml | 6 ++-- .../Views/Home/Purchases.cshtml | 4 +-- 5 files changed, 68 insertions(+), 8 deletions(-) create mode 100644 HardwareShop/HardwareShopClientApp/Views/Home/Privacy.cshtml diff --git a/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs b/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs index 6a67040..bc76ab8 100644 --- a/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs +++ b/HardwareShop/HardwareShopClientApp/Controllers/HomeController.cs @@ -44,9 +44,40 @@ namespace HardwareShopStorekeeperApp.Controllers return View(); } + [HttpGet] public IActionResult Privacy() { - return View(); + if (APIClient.User == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.User); + } + + [HttpPost] + public void Privacy(string login, string email, string password) + { + if (APIClient.User == null) + { + throw new Exception("Вы как сюда попали? Сюда вход только авторизованным"); + } + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) + { + throw new Exception("Введите логин, пароль и почту"); + } + APIClient.PostRequest("api/user/updatedata", new UserBindingModel + { + Id = APIClient.User.Id, + Login = login, + Email = email, + Password = password + }); + + APIClient.User.Login = login; + APIClient.User.Email = email; + APIClient.User.Password = password; + + RedirectToAction("MainStorekeeper", "Storekeeper"); } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] diff --git a/HardwareShop/HardwareShopClientApp/Views/Home/Privacy.cshtml b/HardwareShop/HardwareShopClientApp/Views/Home/Privacy.cshtml new file mode 100644 index 0000000..1984ba8 --- /dev/null +++ b/HardwareShop/HardwareShopClientApp/Views/Home/Privacy.cshtml @@ -0,0 +1,29 @@ +@using HardwareShopContracts.ViewModels; + + +@model UserViewModel + +@{ + ViewData["Title"] = "Privacy Policy"; + Layout = "~/Views/Shared/_LayoutWorker.cshtml"; +} +
+

Личные данные

+
+
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
\ No newline at end of file diff --git a/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs b/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs index dba2e79..d669790 100644 --- a/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs +++ b/HardwareShop/HardwareShopWorkerApp/Controllers/HomeController.cs @@ -76,7 +76,7 @@ namespace HardwareShopWorkerApp.Controllers } if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password)) { - throw new Exception("Введите логин, пароль и ФИО"); + throw new Exception("Введите логин, пароль и почту"); } APIClient.PostRequest("api/user/updatedata", new UserBindingModel { @@ -111,7 +111,7 @@ namespace HardwareShopWorkerApp.Controllers throw new Exception("Введите почту и пароль"); } APIClient.User = APIClient.GetRequest($"api/user/login?email={email}&password={password}"); - if (APIClient.User == null) + if (APIClient.User == null || APIClient.User.Role != UserRole.Работник) { throw new Exception("Неверные почта и/или пароль"); } diff --git a/HardwareShop/HardwareShopWorkerApp/Views/Home/Builds.cshtml b/HardwareShop/HardwareShopWorkerApp/Views/Home/Builds.cshtml index 6dc0d0c..fdcf77d 100644 --- a/HardwareShop/HardwareShopWorkerApp/Views/Home/Builds.cshtml +++ b/HardwareShop/HardwareShopWorkerApp/Views/Home/Builds.cshtml @@ -69,14 +69,14 @@