diff --git a/Tsi1.Api/Tsi1.Api/Controllers/PostController.cs b/Tsi1.Api/Tsi1.Api/Controllers/PostController.cs index a20d5fcfe873a5bebc1a5633e88dca3e1b3643d1..f80f795cd41a71b7ef4cb7d95f23c023d77304cb 100644 --- a/Tsi1.Api/Tsi1.Api/Controllers/PostController.cs +++ b/Tsi1.Api/Tsi1.Api/Controllers/PostController.cs @@ -11,6 +11,7 @@ using Tsi1.BusinessLayer.Interfaces; namespace Tsi1.Api.Controllers { + [Authorize(Roles = UserTypes.Student + ", " + UserTypes.Professor + ", " + UserTypes.FacultyAdmin)] [Route("api/[controller]")] [ApiController] public class PostController : ControllerBase @@ -29,8 +30,6 @@ namespace Tsi1.Api.Controllers _emailService = emailService; } - - [Authorize(Roles = UserTypes.Student + ", " + UserTypes.Professor)] [HttpGet("GetPosts/{forumId}")] public async Task<IActionResult> GetPosts(int forumId) { @@ -44,7 +43,6 @@ namespace Tsi1.Api.Controllers return Ok(result.Data); } - [Authorize(Roles = UserTypes.Student + ", " + UserTypes.Professor)] [HttpPost("Create")] public async Task<IActionResult> Create(PostCreateDto newPost) { @@ -74,7 +72,6 @@ namespace Tsi1.Api.Controllers return Ok(result.Data); } - [Authorize(Roles = UserTypes.Student + ", " + UserTypes.Professor)] [HttpDelete("Delete/{postId}")] public async Task<IActionResult> Delete(int postId) { diff --git a/Tsi1.Api/Tsi1.Api/Controllers/UserController.cs b/Tsi1.Api/Tsi1.Api/Controllers/UserController.cs index 9bc016b50a9ca667e9016e93502424d841d1a0cc..c0eb2126753e8d261e23fd0da4d98ed758b645a2 100644 --- a/Tsi1.Api/Tsi1.Api/Controllers/UserController.cs +++ b/Tsi1.Api/Tsi1.Api/Controllers/UserController.cs @@ -64,17 +64,33 @@ namespace Tsi1.Api.Controllers } var result = new ServiceResult<User>(); + var isStudent = true; if (tenant.Data.IsLoginBedelia) { - var bedeliaResult = await _bedeliaService.Login(userName, request.Password); + var userNotStudent = await _userService.GetByUsername(userName, tenant.Data.Id); - if (bedeliaResult.HasError) + if (!userNotStudent.HasError) { - return BadRequest(bedeliaResult.Message); + if (userNotStudent.Data.UserType.Name != UserTypes.Student.ToString()) + { + result.Data = userNotStudent.Data; + isStudent = false; + } + } - result = await _userService.GetByIdentityCard(userName); + if (isStudent) + { + var bedeliaResult = await _bedeliaService.Login(userName, request.Password); + + if (bedeliaResult.HasError) + { + return BadRequest(bedeliaResult.Message); + } + + result = await _userService.GetByIdentityCard(userName); + } } else { diff --git a/Tsi1.Api/Tsi1.BusinessLayer/DataLoad/DataLoad.cs b/Tsi1.Api/Tsi1.BusinessLayer/DataLoad/DataLoad.cs index a4ef70043b6e9151729d096893da58da272b33be..23b7b937ce3b04529ca116774d181f39ba282f85 100644 --- a/Tsi1.Api/Tsi1.BusinessLayer/DataLoad/DataLoad.cs +++ b/Tsi1.Api/Tsi1.BusinessLayer/DataLoad/DataLoad.cs @@ -147,7 +147,7 @@ namespace Tsi1.BusinessLayer.DataLoad Student = new Student { TenantId = tenantFing.Id, - IdentityCard = "4932876-0", + IdentityCard = "49328760", }, TenantId = tenantFing.Id, }, @@ -164,7 +164,7 @@ namespace Tsi1.BusinessLayer.DataLoad Student = new Student { TenantId = tenantFing.Id, - IdentityCard = "4932877-6", + IdentityCard = "49328776", }, TenantId = tenantFing.Id, }, @@ -177,10 +177,10 @@ namespace Tsi1.BusinessLayer.DataLoad Password = "mathias", FirstName = "Mathias", LastName = "Martinez", - Email = "mathias@mail.com", + Email = "mathias.martinez.fernandez@gmail.com", Student = new Student { - IdentityCard = "1234567-8", + IdentityCard = "50540723", TenantId = tenantFing.Id, }, TenantId = tenantFing.Id, @@ -244,11 +244,11 @@ namespace Tsi1.BusinessLayer.DataLoad Password = "rodriguez", FirstName = "Marcelo", LastName = "Rodriguez", - Email = "marcelo@gmail.com", + Email = "cmarceorp@gmail.com", Student = new Student { TenantId = tenantFmed.Id, - IdentityCard = "76347887-0", + IdentityCard = "42567630", }, TenantId = tenantFmed.Id, }, @@ -265,7 +265,7 @@ namespace Tsi1.BusinessLayer.DataLoad Student = new Student { TenantId = tenantFmed.Id, - IdentityCard = "73642873-6", + IdentityCard = "46728282", }, TenantId = tenantFmed.Id, },