From 10cd041d38f79617945bcd78a9a56a00b60da6ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Sun, 20 Dec 2020 15:57:10 +0100 Subject: [PATCH 1/2] Fixed bug with registering the same user multiple times --- .../Controllers/UserController.cs | 7 ++++--- .../SessionCompanion/SessionCompanion.xml | 16 +++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/SessionCompanion/SessionCompanion/Controllers/UserController.cs b/SessionCompanion/SessionCompanion/Controllers/UserController.cs index ec8607a..42b2f64 100644 --- a/SessionCompanion/SessionCompanion/Controllers/UserController.cs +++ b/SessionCompanion/SessionCompanion/Controllers/UserController.cs @@ -61,16 +61,17 @@ namespace SessionCompanion.Controllers public async Task> Register(UserRegisterViewModel userRegisterModel) { if (!ModelState.IsValid) - { return new ErrorResponse() { StatusCode = 400, Message = "Given model is incorect" }; - } + + if (await _service.SearchUserByUsername(userRegisterModel.Username) is not null) + return new ErrorResponse() { StatusCode = 400, Message = "Given user is already registered" }; UserViewModel userModel = new UserViewModel() { Password = userRegisterModel.Password, Username = userRegisterModel.Username }; - + var user = await _service.SearchUserByUsername(userRegisterModel.Username); await _service.Create(userModel); await _service.SaveAsync(); diff --git a/SessionCompanion/SessionCompanion/SessionCompanion.xml b/SessionCompanion/SessionCompanion/SessionCompanion.xml index 13641ce..507803a 100644 --- a/SessionCompanion/SessionCompanion/SessionCompanion.xml +++ b/SessionCompanion/SessionCompanion/SessionCompanion.xml @@ -11,6 +11,13 @@ Identyfikator postaci ViewModel Postaci/ErrorResponse + + + Metoda zwraca listę postaci przypisanych do danego użytkownika + + Identyfikator użytkownika + Lista postać lub wiadomość błędu + Metoda przyjmuje login oraz hasło i sprawdza czy istnieje użytkownik o podanych parametrach @@ -32,14 +39,9 @@ true jesli ktoś jest już zalogowany i false jeśli nie - + - Lista zalogowanych graczy i identyfikator wybranej postaci - - - - - Status, czy GM został już zalogowany + Klasa zawierająca wszystkie dane potrzebne w SignalR odnośnie aktualnej sesji -- 2.20.1 From d6db2b6b56f2f1ff2acbf0eeefb6c255ac353ea1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20G=C3=B3rzy=C5=84ski?= Date: Sun, 20 Dec 2020 15:59:42 +0100 Subject: [PATCH 2/2] Fixed unnecessary call --- SessionCompanion/SessionCompanion/Controllers/UserController.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/SessionCompanion/SessionCompanion/Controllers/UserController.cs b/SessionCompanion/SessionCompanion/Controllers/UserController.cs index 42b2f64..0f8f9d7 100644 --- a/SessionCompanion/SessionCompanion/Controllers/UserController.cs +++ b/SessionCompanion/SessionCompanion/Controllers/UserController.cs @@ -71,7 +71,6 @@ namespace SessionCompanion.Controllers Password = userRegisterModel.Password, Username = userRegisterModel.Username }; - var user = await _service.SearchUserByUsername(userRegisterModel.Username); await _service.Create(userModel); await _service.SaveAsync(); -- 2.20.1