Skip to content

Mahitha taking over: complete server date protection for timelog and weekly summary#2271

Open
Mahitha-pasupuleti wants to merge 2 commits into
developmentfrom
MahithaPasupuleti--ResolvedServerDateIssue-Backend
Open

Mahitha taking over: complete server date protection for timelog and weekly summary#2271
Mahitha-pasupuleti wants to merge 2 commits into
developmentfrom
MahithaPasupuleti--ResolvedServerDateIssue-Backend

Conversation

@Mahitha-pasupuleti

@Mahitha-pasupuleti Mahitha-pasupuleti commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

Implements: #4312 (Priority: High)
Screenshot 2026-07-15 at 2 49 20 PM

This PR resolves the issue where users could bypass time entry validation by changing their local system date. Previously, the frontend relied on the client's local time, allowing users to log time for incorrect dates by modifying their device clock.

This implementation updates the frontend to fetch the current server time before creating a time entry. Time entry validation now uses the server date instead of the local system date, preventing users from logging time on dates other than the current server date.

Related Issue

  • Priority High: Finish abandoned PR #5129 – Resolved Server Date Issue Frontend (#4312)

Related PRs

  • Frontend PR: PR #5390
  • Backend PR: This PR

To test this feature, check out both the frontend and backend PRs.


Main changes explained

  • Added a new serverTime utility to retrieve the current backend server time.
  • Updated postTimeEntry() to fetch the latest server time before submitting a time entry.
  • Replaced local system date validation with server-based date validation.
  • Prevented users from logging time for any date other than the current server date.
  • Displayed an error message when attempting to log time for a different day.

How to test

  1. Check out both the frontend and backend branches.

  2. Run:

    npm install
    npm start
  3. Clear the browser cache/site data.

  4. Log in as an admin user.

  5. Navigate to Dashboard → Tasks → Select a task → Log Time.

  6. Verify that logging time for the current server date succeeds.

  7. Change your computer's system date to a previous or future day.

  8. Attempt to log time again.

  9. Verify that:

    • The application displays "You can only log time for today."
    • No time entry is created.
  10. Reset your system clock and verify that logging time for the current date works as expected.


Screenshots or Videos

Video demonstration:
https://youtu.be/ziEJpHzcmX8


Note

This PR depends on the corresponding backend PR, which introduces the /api/servertime endpoint used for server-based date validation.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

💡 Need a hand with PR review? Try Gitar by Sonar!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant