I want to create smart contract for login. When users input username and password are correct its will return true and incorrect return false to my web application.
Model
participant SampleParticipant identified by participantId {
o String participantId
o String username
o String password
}
transaction SampleLogin {
--> SampleParticipant participant
o String inputUsername
o String inputPassword
}
Transaction
function sampleLogin(tx) {
var username = tx.participant.username;
var password = tx.participant.password;
var inputUsername = tx.inputUsername;
var inputPassword = tx.inputPassword;
if (username == inputUsername && password == inputPassword){
//return true;
}else{
//return false;
}
}
I want get with this. https://localhost:3000/api/SampleLogin
return True or False
The TP returns a 200 from the REST API (transaction submitted). The TP returns a Promise which can be resolved as a Boolean, having value either true or false - depending on your result (above). You wouldn't
return
out from the TP. Seems to me your login code would be better in a client app - otherwise you're creating a transaction for each and every login set, good or bad and with the id and password stored in the ledger. Is this what you want?