javascriptnode.jsdatetimewebsecuritysecure-coding

Is it Safe to Compare Subscription-Expiration-Date & Current-Date on the Client Side? Or can this be manipulated?


I get some data back from the backend, which tells me the expiration date of the user subscription. If this date is in the past, I navigate the user somewhere else, so she can't log in:

  if (expirationDate.getTime() < new Date().getTime()) {
      navigate('/subscription-expired')
  }

I am wondering whether it's safe to do a check like this comparison on the client? Can this be manipulated?


Solution

  • The Benefits of checking data, validating data and other stuff on the Client side is:

    but checking on the Server side is an Obligation, since there are non-regular users (whos modifies Js, posting data with Postman, bots, intruders ) which may send Http requests without intervention and validation of your client-side code could abuse your system.

    Client side is the battle field of enemy

    To summarize:

    you have to validate data on server side in order to prevent any abusing.

    but its recommended to validate data on the client side too to improve performance of the whole system.

    for example in your case: