diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-05-07 11:59:29 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2021-05-07 11:59:29 +0300 |
| commit | 8f7dabf274b5e428fc32f19a3c8848eacab01090 (patch) | |
| tree | b738b66fa6621ed88b199e820702cae16422f9ba /ExamTemplate/Web/Controllers | |
| parent | bd2ebdd29e03425a8314a91b64a5943df83b7559 (diff) | |
| download | it-kariera-exam-template-8f7dabf274b5e428fc32f19a3c8848eacab01090.tar it-kariera-exam-template-8f7dabf274b5e428fc32f19a3c8848eacab01090.tar.gz it-kariera-exam-template-8f7dabf274b5e428fc32f19a3c8848eacab01090.zip | |
Added view model validation for register and login
Diffstat (limited to 'ExamTemplate/Web/Controllers')
| -rw-r--r-- | ExamTemplate/Web/Controllers/UserController.cs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/ExamTemplate/Web/Controllers/UserController.cs b/ExamTemplate/Web/Controllers/UserController.cs index 4a22de7..622a616 100644 --- a/ExamTemplate/Web/Controllers/UserController.cs +++ b/ExamTemplate/Web/Controllers/UserController.cs @@ -29,6 +29,9 @@ namespace ExamTemplate.Web.Controllers [Route("/Register")] public async Task<IActionResult> Register(RegisterUserViewModel registerUserViewModel) { + if (!ModelState.IsValid) + return View(registerUserViewModel); + RegisterUserServiceModel registerUserServiceModel = this._autoMapper.Map<RegisterUserServiceModel>(registerUserViewModel); bool result = await this._userService.RegisterUserAsync(registerUserServiceModel); @@ -50,6 +53,9 @@ namespace ExamTemplate.Web.Controllers [Route("/Login")] public async Task<IActionResult> Login(LoginUserViewModel loginUserViewModel) { + if (!ModelState.IsValid) + return View(loginUserViewModel); + LoginUserServiceModel loginUserServiceModel = this._autoMapper.Map<LoginUserServiceModel>(loginUserViewModel); bool result = await this._userService.LoginUserAsync(loginUserServiceModel); |
