I mean here, after it calls login() to add a console.log
Sorry for not understanding you the first time. The console.log after login(); logs before opening MM. So this works.
it means that you should add an await before that login, it shouldnât log before metamask appears
Here is what happens. The onclick function doesnât work when I add await to the function before login.
Without await login();
Everything works up until the if statement
document.getElementById("btn-login").onclick = function() {
login();
if(!isAuthenticated, user) {
console.log("worked");
}
else if(authError) {
console.log(authError);
}
};
I think that you have to define async that function for onclick to make it work
Do you mean that I need to create an async function for isAuthenticated?
My eventual goal is to call the Bootstrap Modal when isAuthenticated verifies the signingmessage click on MetaMask. So far I am able to click on my âSign for Airdropâ button to open MetaMask and sign the message. This is all going smoothly.
I am struggling with displaying the Modal after the signingmessage. isAuthenticated does not work, but also I donât know how to display the Bootstrap Modal.
I mean this function to be async so what you can use await in the function code
Okay so I was able to add async to the onclick and added await like this:
document.getElementById("btn-login").onclick = async() =>{
await login();
if(!isAuthenticated, user) {
console.log("log this");
}
else if(authError) {
}
}
However, isAuthenticated still does nothing.
you have to get the value for isAuthenticated, it doesnât change automatically
I want it to return the modal. How do I do that?
I donât know how you can return a modal, I donât know what you mean by returning a modal either
Here is a screenshot of a Bootstrap Modal. I am perhaps trying to achieve something that isnât as straightforward, but I am hoping to find the answer to whether I should use this or not.
This looks like something that you can generate to show it, not sure what you mean by returning it, maybe you only want to display it
Yes I want to show it after the MetaMask signingmessage. I just havenât been able to achieve this. This is the bootstrap modal in my index.html file.
<!-- Modal -->
<div class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<p>Modal body text goes here.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary">Save changes</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
what does that if do with 2 parameters?
I canât do anything with !isAuthenticated I tried a few things, but it doesnât do anything.
isnât this part equivalent with isAuthenticated? if user is defined, then it is authenticated?
I am not sure. Because yes, you are right that it is already authenticated but after that user = await Moralis.authenticate({signingMessage:
and I click the sign message in MetaMask, that is when I need it to show the modal. Someone on discord advised me to use isAuthenticated. It is why I am trying to use it like this.
isAuthenticated may be related to react, current code seems to be vanilla js
Is there a way to do it in vanilla js?