isAuthenticated for Modal

I am running an async function for login();

async function login() {
    let user = Moralis.User.current();
        if(!user) {
            user = await Moralis.authenticate({signingMessage:"You are signing to enter the Airdrop."}); 
                  
        }
            
        console.log("Your Wallet address has been submitted to enter the Airdrop.", user);
 
      
    }

ok, can you add a console.log after calling that login function to see if that message appears before metamask appears?

So just making sure I understand this correctly. Add the console.log after this part?

async function login() {

no, not in this function, after you call this function

So I console.log after the async function but it does not do anything. It also disables the click functions of the buttons.

After the async function login(), I also have an async function logout() . The console.log you have mentioned for me to try, I have placed in between these two functions.

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">&times;</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?