Registration, Login and Forgot Password using Google Spreadsheet

Need to see the full output of responseContent when you press Register

i put as only only with restricted people

anyway now i fixed it. It works

Btw I have to clearfy some things form you so i will have the opportunity to learn something new.

First of all, when I have imported your .aia project to mit app inventor i don't see another screen which should be one of login and another for registered. i can see only one screen1

So in that project, did u implement login, registration page as web view component? instead of using components from mit's designer section?

then can u please explain me each part of blocks, how they work in the porject?

finally, if we implement user authentication page as a web component viewer, if we wanna implement, html, bootstrap, what changes do i have to do in app scripts and in blocks

Everything is on one screen, using virtual screens (hide and show arrangements)

No, see above

You will simply need to follow the blocks/components logic to understand how it works

Yes, that will quite a different app... why use the webviewer when everything is handled already in the app?

now i got it, thank you so much

Anyway, for other uses, let's say the authentication is just a part of a project . After the login process, what if we wanna retrieve an user information who logged in, for other purposes? can we do that as we are using google spreedsheet?

You can use the spreadsheet data for other purposes, of course, you need to protect the real passwords used by users...

Would you mind helping me, how to build an app where we will upload an electronic component image and our app will tell what type of component it is by analyzing the image?

I already have gemini AI's API key for that? so in our case we need an app where you have to choose an image form ur phone's gallary, then the AI will automatically analyze our image through the api key then give us an answer through json data i guess?

so how can we build the app? would you mind helping me out to build the app?

Start a new topic for this.

I cannot help with AI.

1 Like

Hey Tim, I really need help.

I am struggeling to add another collum in google sheet call Uname which should be username

what changes to do in mit app inventor's block, changes in the app script

please help me

Add the column to your google sheet, then methodically work through your apps script and app blocks to account for the new column. Nothing fancy or difficult to do.

I did it

here's the script below. i dont know whats the issue, maybe i am having issues with blocks, Please help me

function doPost(e) {
var ss = SpreadsheetApp.openById('g');
var sh = ss.getSheetByName("Sheet1");
var msg;

if (e.parameter.fn == "getusers" ) {
var loginData = sh.getDataRange().getValues();
var users = ;
for ( var i = 1; i < loginData.length; i++ ) {
users.push(loginData[i][0]);
}
msg = JSON.stringify(users);
}
else if ( e.parameter.fn == "register" ) {
sh.appendRow([e.parameter.uname, e.parameter.email, e.parameter.pass]); // Add username to the row
msg = "user registered";
}
else if ( e.parameter.fn == "login" ) {
var loginData = sh.getDataRange().getValues();
for ( var i = 0; i < loginData.length; i++ ) {
if ( e.parameter.email == loginData[i][1] && e.parameter.pass == loginData[i][2] ) { // Check email and password
msg = "user logged in";
}
}
}
else if ( e.parameter.fn == "reset" ) {
var newpass = makePasswd();
var newHash = makeHash(newpass,e.parameter.key);
var loginData = sh.getDataRange().getValues();
for ( var i = 0; i < loginData.length; i++ ) {
if ( e.parameter.email == loginData[i][1]) {
var rngp = sh.getRange(i+1,3);
rngp.setValue(newHash);
msg = "password reset";
}
}
GmailApp.sendEmail(e.parameter.email,"From AI2 App","Your new password is: " + newpass + "\n\n Use this new password to login.\n\n Thank you.");
}
return ContentService.createTextOutput(msg);
}

function makePasswd() {
var passwd = '';
var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!.#*@_';
for (i=1;i<8;i++) {
var c = Math.floor(Math.random()*chars.length + 1);
passwd += chars.charAt(c)
}
return passwd;
}

function makeHash(message,key){
var getHash = Utilities.computeHmacSha256Signature(message,key).reduce(function(str,chr){
chr = (chr < 0 ? chr + 256 : chr).toString(16);
return str + (chr.length==1?'0':'') + chr;
},'');;
return getHash;
}

someone please help me

it would be very helpful for me to understand what's the error, I'm not an expert to find the error, you guys are at the top level

Are the email and password still in columns 1 and 2?

here it is, would you help me to fix the blocks, for login i just use email and password, they retrieve the username in the logout page

If you want uname in the third col, then the appendRow is wrong...like now, you are adding the uname in the first one.

I fixed it, its now after Pass

so now what to fix in the blocks
please help me out

What I was telling to you is that if you want the uname parameter in third col, appendRow must have uname parameter in third position...but email and password then are in pos 0 and 1, respectively.

What additional problems do you have?

I am having issues with block's

do u want me to share with you blocks?

Can you explain which issues do you have?

sure,

here's what i have added below, once i registered, i go back to the spreedsheet to check, but uname collum is empty, i dont see any data related to uname, i can only see email and hashed password.

I have already fixed what u said before "What I was telling to you is that if you want the uname parameter in third col, appendRow must have uname parameter in third position...but email and password then are in pos 0 and 1, respectively."

Can you check if username.Text has something there, just when calling to PostText (register)?