Advertisement
A_God

Appscript

Dec 13th, 2021
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function doGet(e){
  2.  
  3.   return Authentication(e);
  4.  
  5. }
  6.  
  7. function doPost(e){
  8.  
  9.   return Authentication (e);
  10. }
  11.  
  12. function Authentication(e){
  13.  
  14.  
  15.   if (e.parameter.func=="Create") {
  16.  
  17.     var ss = SpreadsheetApp.openById(e.parameter.ID);
  18.     var sh = ss.getSheetByName(e.parameter.SH);
  19.     var rg = sh.getName() + "!" + sh.getDataRange().getA1Notation();
  20.     var email= e.parameter.email;
  21.     var sql = '"Select B where B=\'' +email+'\'"';
  22.     var qry = 'IFERROR(query('+rg + ','+ sql +'),""';
  23.     var ts = ss.insertSheet();
  24.     var setQuery = ts.getRange(1,1).setFormula(qry);
  25.     var getreslut = ts.getDataRange().getValues();
  26.     ss.deleteSheet(ts);
  27.     if (getreslut==""){
  28.    
  29.     var dara = [e.parameter.tlid, e.parameter.email, e.parameter.password, e.parameter.phone];
  30.     sh.appendRow(dara);
  31.  
  32.     return ContentService.createTextOutput("getreslut");}
  33.   }
  34.   //-------------------------------------------------------------------
  35.   //needd diffrent SheetID to be passed in the paramenter(data sheet)
  36.   if (e.parameter.func=="Login"){
  37.     var ss = SpreadsheetApp.openById(e.parameter.ID);
  38.     var sh = ss.getSheetByName(e.parameter.SH);
  39.  
  40.     var email = e.parameter.email;
  41.     var password = e.parameter.password;
  42.  
  43.     var rg = sh.getName() + "!" + sh.getDataRange().getA1Notation();
  44.     var sql = '"Select A,B,C,D where B=\''+email+'\'" ';
  45.     var qry = '=IFERROR(query('+ rg +','+ sql +'),"")'; //formula
  46.  
  47.     var ts = ss.insertSheet();
  48.     var setQuery = ts.getRange(1,1).setFormula(qry);
  49.     var getreslut = ts.getDataRange().getValues();
  50.  
  51.     var getPWD =  ts.getRange(1,3).getValues();
  52.     var getemail = ts.getDataRange(1,2).getValues();
  53.     ss.deleteSheet(ts);
  54.  
  55.       if (getreslut!=""){
  56.  
  57.         if(getPWD==password){return ContentService.createTextOutput(getemail);}
  58.         else { return ContentService.createTextOutput("ERPWD");}
  59.       }
  60.       else {return  ContentService.createTextOutput(getreslut)}
  61.  
  62.   }
  63. }
  64.  
  65.    //if (e.parameter.func=="List"){
  66.   function test(){
  67.       var ss = SpreadsheetApp.openById("1I4OmVach96qOG_RU0OvEkcW8sFDUF_wtbrZuvYR1F-g");
  68.       var sh = ss.getSheetByName('CONDITIONAL');
  69.       var rg = sh.getDataRange().getValues();
  70.  
  71.     // var ss = SpreadsheetApp.openById(e.parameter.ID);
  72.     // var sh = ss.getSheetByName(e.parameter.SH);
  73.     // var rg = sh.getRange().getValues();
  74.  
  75.     var outString= '';
  76.       for(var row = 0; row<rg.length; ++row ){
  77.       outString += rg[row].join('') + '\n';
  78.       Logger.log(outString);
  79.       }
  80.      
  81.       Logger.log(outString.typeof)
  82.     //return ContentService.createTextOutput(outString).setMimeType(ContentService.MimeType.TEXT);
  83.   }
  84.  
  85. function formula(){
  86.  
  87.  
  88.   var ss = SpreadsheetApp.openById("1I4OmVach96qOG_RU0OvEkcW8sFDUF_wtbrZuvYR1F-g");
  89.   var sh = ss.getSheetByName()
  90.  
  91.  
  92.  
  93.  
  94. }
  95.    
  96.  
  97.  
  98.  
  99.  
  100.    
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement