Html Google sheet and mit app validity i

I wanted to make a validity using Google sheet when userlogin inot app it decreases the value in sheet and when value reaches 0 is stops decreasing and send message to app that validity is expired

1 Like

Maintain a counter in the user details row, and reduce this by 1 each time they login.

Something like this (in your google apps script web app):

if ( e.parameter.fn == "login" ) {
  var loginData = sh.getDataRange().getValues();
   for ( var i = 0; i < loginData.length; ++i ) {
     if ( e.parameter.email == loginData[i][0] && e.parameter.pass == loginData[i][1] && loginData[i][2] > 0 ) {
       var rngCounter = sh.getRange(i+1,3);
       var counter = rngCounter.getValue();
       rngCounter.setValue(counter - 1);
       msg = "user logged in";
     } else  if(loginData[i][2] == 0) {
       msg = "login no longer valid";
   }
1 Like