GAS AI BuilderApps Script Assistant Sign in

Who is using the app, and their role

Apps Script recipes › Web app

Reads the visitor's email and looks up their role in a Users tab; server functions check it before doing anything.

File Code.gs

/** { email, role } of the visitor; role from the Users tab (Email, Role), 'viewer' when not listed. */
function currentUser() {
  const email = Session.getActiveUser().getEmail().toLowerCase();
  const rows = SpreadsheetApp.openById(SHEET_ID).getSheetByName('Users').getDataRange().getValues().slice(1);
  const row = rows.find(r => String(r[0]).toLowerCase() === email);
  return { email, role: row ? String(row[1]).toLowerCase() : 'viewer' };
}

function requireRole_(...roles) {
  const user = currentUser();
  if (!roles.includes(user.role)) throw new Error('You do not have access to this.');
  return user;
}

function deleteOrder(id) {
  requireRole_('admin');
  return deleteRow_('Orders', id);
}

Good to know

Let the AI put it in your appGAS AI Builder knows every recipe here. Describe your app and it uses this code where it fits, in a Google Apps Script project in your own Drive.

Use it in a project

More in Web app

doGet with pages split into filesindex.html pulls in css/app.html and js/app.html with include(); works on phones and inside an iframe.Call the server from the page with async/awaitA small helper turns google.script.run into a promise, with errors shown instead of lost.Return data the page can readTurns dates into text and drops values the page can't receive, so a result never arrives as null.Upload a file from the page to DriveThe page reads the chosen file as base64 and sends it; the server saves it in a folder and returns its link.