OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Navigate to the next page if a password input is correct

  • Thread starter Thread starter Hyborn Incoporated
  • Start date Start date
H

Hyborn Incoporated

Guest
I am handling a project in app script and I am done with the web app but need a login before users can access the app/form. But I am having issues creating a login page as I want to create username and password input if correct before users can be allowed to proceed from login page to app page. Please help me here is my server code.

Code:
function doGet(e) {
  if (e.parameters.page == "apppage"){
  return loadAppPage();
}
else{
  return loadLoginPage();
}


function loadLoginPage(){
  return HtmlService.createTemplateFromFile('loginPage').evaluate();
}

function loadLoginPage(){
  return HtmlService.createTemplateFromFile('loginPage').evaluate();
}

JavaScript Code:

Code:
document.getElementById('loginbutton').addEventListener ('click', getlogin); 

function getlogin(){
  var username= document.getElementById ('username').value; 
  var password= document.getElementById ('password').value; 
  if(username=='admin' && password == 'admin123'){
   loginbutton.setAttribute("href",ScriptApp.getService().getUrl()+loginPage);
  }
}

<p>I am handling a project in app script and I am done with the web app but need a login before users can access the app/form. But I am having issues creating a login page as I want to create username and password input if correct before users can be allowed to proceed from login page to app page. Please help me here is my server code.</p>

<pre><code>function doGet(e) {
if (e.parameters.page == "apppage"){
return loadAppPage();
}
else{
return loadLoginPage();
}


function loadLoginPage(){
return HtmlService.createTemplateFromFile('loginPage').evaluate();
}

function loadLoginPage(){
return HtmlService.createTemplateFromFile('loginPage').evaluate();
}
</code></pre>

<p>JavaScript Code:</p>

<pre><code>document.getElementById('loginbutton').addEventListener ('click', getlogin);

function getlogin(){
var username= document.getElementById ('username').value;
var password= document.getElementById ('password').value;
if(username=='admin' && password == 'admin123'){
loginbutton.setAttribute("href",ScriptApp.getService().getUrl()+loginPage);
}
}
</code></pre>
 

Latest posts

Top