From 2a6ab929d91ea50a872ebf6d7b8e2eac9e606994 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Mar 2025 13:08:50 +0530 Subject: [PATCH 1/6] Added the condition to check if received token for reset password is encoded or not --- .../Controllers/AuthController.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Marco.Pms.Services/Controllers/AuthController.cs b/Marco.Pms.Services/Controllers/AuthController.cs index 2259142..6b8a2bb 100644 --- a/Marco.Pms.Services/Controllers/AuthController.cs +++ b/Marco.Pms.Services/Controllers/AuthController.cs @@ -162,12 +162,28 @@ namespace MarcoBMS.Services.Controllers UserManager.ResetPasswordTokenPurpose, WebUtility.UrlDecode( model.Token) ); - + string token = ""; if (!isTokenValid) - return BadRequest("Invalid or expired token."); + { + var isDecodedTokenValid = await _userManager.VerifyUserTokenAsync( + user, + TokenOptions.DefaultProvider, // This is the token provider + UserManager.ResetPasswordTokenPurpose, + model.Token + ); + if(!isDecodedTokenValid) + return BadRequest("Invalid or expired token."); - var result = await _userManager.ResetPasswordAsync(user, WebUtility.UrlDecode(model.Token), model.NewPassword); + token = model.Token; + } + else + { + token = WebUtility.UrlDecode(model.Token); + } + + + var result = await _userManager.ResetPasswordAsync(user, token, model.NewPassword); if (!result.Succeeded) return BadRequest(result.Errors); From 354680d28b5be56a72f15c6fa8e4e9f529c707d0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Mar 2025 13:45:06 +0530 Subject: [PATCH 2/6] Solved time discrepancies in attendance/record --- .../Controllers/AttendanceController.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Marco.Pms.Services/Controllers/AttendanceController.cs b/Marco.Pms.Services/Controllers/AttendanceController.cs index 37b3471..3103b9b 100644 --- a/Marco.Pms.Services/Controllers/AttendanceController.cs +++ b/Marco.Pms.Services/Controllers/AttendanceController.cs @@ -219,6 +219,8 @@ namespace MarcoBMS.Services.Controllers Attendance attendance = await _context.Attendes.FirstOrDefaultAsync(a => a.EmployeeID == recordAttendanceDot.EmployeeID && a.AttendanceDate.Date == recordAttendanceDot.Date.Date && a.TenantId == TenantId); ; + DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); + if (attendance != null) { @@ -236,13 +238,13 @@ namespace MarcoBMS.Services.Controllers //string timeString = "10:30 PM"; // Format: "hh:mm tt" - DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); + //DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); attendance.OutTime = finalDateTime; } else if (recordAttendanceDot.Action == ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE) { - DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); + //DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); attendance.OutTime = finalDateTime; attendance.Activity = ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE; @@ -277,7 +279,7 @@ namespace MarcoBMS.Services.Controllers attendance.Date = DateTime.UtcNow; - DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); + //DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); attendance.InTime = finalDateTime; attendance.OutTime = null; @@ -295,7 +297,7 @@ namespace MarcoBMS.Services.Controllers AttendanceId = attendance.Id, // Use existing or new AttendanceId Activity = attendance.Activity, - ActivityTime = recordAttendanceDot.Date, + ActivityTime = finalDateTime, Comment = recordAttendanceDot.Comment, EmployeeID = recordAttendanceDot.EmployeeID, Latitude = recordAttendanceDot.Latitude, @@ -303,7 +305,7 @@ namespace MarcoBMS.Services.Controllers TenantId = TenantId, UpdatedBy = GetUserId(), - UpdatedOn = DateTime.UtcNow + UpdatedOn = recordAttendanceDot.Date }; //if (recordAttendanceDot.Image != null && recordAttendanceDot.Image.Count > 0) //{ From 8b4f892edfc5eaab3461ac876baaeebe08dc0e0b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Mar 2025 13:45:06 +0530 Subject: [PATCH 3/6] Solved time discrepancies in attendance/record --- .../Controllers/AttendanceController.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Marco.Pms.Services/Controllers/AttendanceController.cs b/Marco.Pms.Services/Controllers/AttendanceController.cs index 37b3471..3103b9b 100644 --- a/Marco.Pms.Services/Controllers/AttendanceController.cs +++ b/Marco.Pms.Services/Controllers/AttendanceController.cs @@ -219,6 +219,8 @@ namespace MarcoBMS.Services.Controllers Attendance attendance = await _context.Attendes.FirstOrDefaultAsync(a => a.EmployeeID == recordAttendanceDot.EmployeeID && a.AttendanceDate.Date == recordAttendanceDot.Date.Date && a.TenantId == TenantId); ; + DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); + if (attendance != null) { @@ -236,13 +238,13 @@ namespace MarcoBMS.Services.Controllers //string timeString = "10:30 PM"; // Format: "hh:mm tt" - DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); + //DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); attendance.OutTime = finalDateTime; } else if (recordAttendanceDot.Action == ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE) { - DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); + //DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); attendance.OutTime = finalDateTime; attendance.Activity = ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE; @@ -277,7 +279,7 @@ namespace MarcoBMS.Services.Controllers attendance.Date = DateTime.UtcNow; - DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); + //DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); attendance.InTime = finalDateTime; attendance.OutTime = null; @@ -295,7 +297,7 @@ namespace MarcoBMS.Services.Controllers AttendanceId = attendance.Id, // Use existing or new AttendanceId Activity = attendance.Activity, - ActivityTime = recordAttendanceDot.Date, + ActivityTime = finalDateTime, Comment = recordAttendanceDot.Comment, EmployeeID = recordAttendanceDot.EmployeeID, Latitude = recordAttendanceDot.Latitude, @@ -303,7 +305,7 @@ namespace MarcoBMS.Services.Controllers TenantId = TenantId, UpdatedBy = GetUserId(), - UpdatedOn = DateTime.UtcNow + UpdatedOn = recordAttendanceDot.Date }; //if (recordAttendanceDot.Image != null && recordAttendanceDot.Image.Count > 0) //{ From 93a25690f1922e6e3260020bce34acb837d94499 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 31 Mar 2025 11:23:30 +0530 Subject: [PATCH 4/6] Fixed project duplicate bug appered due to absence of projectId --- Marco.Pms.Model/Mapper/ProjectMapper.cs | 3 ++- Marco.Pms.Services/Controllers/ProjectController.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Marco.Pms.Model/Mapper/ProjectMapper.cs b/Marco.Pms.Model/Mapper/ProjectMapper.cs index 6801a11..6dc0986 100644 --- a/Marco.Pms.Model/Mapper/ProjectMapper.cs +++ b/Marco.Pms.Model/Mapper/ProjectMapper.cs @@ -34,10 +34,11 @@ namespace Marco.Pms.Model.Mapper }; } - public static Project ToProjectFromUpdateProjectDto(this UpdateProjectDto projectModel, int TenantId) + public static Project ToProjectFromUpdateProjectDto(this UpdateProjectDto projectModel, int TenantId,int id) { return new Project { + Id = id, ContactPerson = projectModel.ContactPerson, ProjectAddress = projectModel.ProjectAddress, Name = projectModel.Name, diff --git a/Marco.Pms.Services/Controllers/ProjectController.cs b/Marco.Pms.Services/Controllers/ProjectController.cs index 4ca7a23..ef98a1b 100644 --- a/Marco.Pms.Services/Controllers/ProjectController.cs +++ b/Marco.Pms.Services/Controllers/ProjectController.cs @@ -197,7 +197,7 @@ namespace MarcoBMS.Services.Controllers int TenantId = GetTenantId(); updateProjectDto.TenantId = TenantId; - Project project = updateProjectDto.ToProjectFromUpdateProjectDto(TenantId); + Project project = updateProjectDto.ToProjectFromUpdateProjectDto(TenantId,id); _context.Projects.Update(project); await _context.SaveChangesAsync(); From 35da59304d0a0413ed41faafcbcc81900329e6d8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Mar 2025 13:08:50 +0530 Subject: [PATCH 5/6] Added the condition to check if received token for reset password is encoded or not --- .../Controllers/AuthController.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Marco.Pms.Services/Controllers/AuthController.cs b/Marco.Pms.Services/Controllers/AuthController.cs index 2259142..6b8a2bb 100644 --- a/Marco.Pms.Services/Controllers/AuthController.cs +++ b/Marco.Pms.Services/Controllers/AuthController.cs @@ -162,12 +162,28 @@ namespace MarcoBMS.Services.Controllers UserManager.ResetPasswordTokenPurpose, WebUtility.UrlDecode( model.Token) ); - + string token = ""; if (!isTokenValid) - return BadRequest("Invalid or expired token."); + { + var isDecodedTokenValid = await _userManager.VerifyUserTokenAsync( + user, + TokenOptions.DefaultProvider, // This is the token provider + UserManager.ResetPasswordTokenPurpose, + model.Token + ); + if(!isDecodedTokenValid) + return BadRequest("Invalid or expired token."); - var result = await _userManager.ResetPasswordAsync(user, WebUtility.UrlDecode(model.Token), model.NewPassword); + token = model.Token; + } + else + { + token = WebUtility.UrlDecode(model.Token); + } + + + var result = await _userManager.ResetPasswordAsync(user, token, model.NewPassword); if (!result.Succeeded) return BadRequest(result.Errors); From 58526d5feb9ead812e02f71626c91950bb642d78 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Mar 2025 13:45:06 +0530 Subject: [PATCH 6/6] Solved time discrepancies in attendance/record --- .../Controllers/AttendanceController.cs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Marco.Pms.Services/Controllers/AttendanceController.cs b/Marco.Pms.Services/Controllers/AttendanceController.cs index 37b3471..3103b9b 100644 --- a/Marco.Pms.Services/Controllers/AttendanceController.cs +++ b/Marco.Pms.Services/Controllers/AttendanceController.cs @@ -219,6 +219,8 @@ namespace MarcoBMS.Services.Controllers Attendance attendance = await _context.Attendes.FirstOrDefaultAsync(a => a.EmployeeID == recordAttendanceDot.EmployeeID && a.AttendanceDate.Date == recordAttendanceDot.Date.Date && a.TenantId == TenantId); ; + DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); + if (attendance != null) { @@ -236,13 +238,13 @@ namespace MarcoBMS.Services.Controllers //string timeString = "10:30 PM"; // Format: "hh:mm tt" - DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); + //DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); attendance.OutTime = finalDateTime; } else if (recordAttendanceDot.Action == ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE) { - DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); + //DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); attendance.OutTime = finalDateTime; attendance.Activity = ATTENDANCE_MARK_TYPE.REQUEST_REGULARIZE; @@ -277,7 +279,7 @@ namespace MarcoBMS.Services.Controllers attendance.Date = DateTime.UtcNow; - DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); + //DateTime finalDateTime = GetDateFromTimeStamp(recordAttendanceDot, recordAttendanceDot.MarkTime); attendance.InTime = finalDateTime; attendance.OutTime = null; @@ -295,7 +297,7 @@ namespace MarcoBMS.Services.Controllers AttendanceId = attendance.Id, // Use existing or new AttendanceId Activity = attendance.Activity, - ActivityTime = recordAttendanceDot.Date, + ActivityTime = finalDateTime, Comment = recordAttendanceDot.Comment, EmployeeID = recordAttendanceDot.EmployeeID, Latitude = recordAttendanceDot.Latitude, @@ -303,7 +305,7 @@ namespace MarcoBMS.Services.Controllers TenantId = TenantId, UpdatedBy = GetUserId(), - UpdatedOn = DateTime.UtcNow + UpdatedOn = recordAttendanceDot.Date }; //if (recordAttendanceDot.Image != null && recordAttendanceDot.Image.Count > 0) //{