Why isn't my code working?

Question:
Why isn’t my code working? it’s supposed to be a admin page


Repl link:
https://inspiration-a-day.sonicx180.repl.co/admin

<!doctype html>
<html>
  <head>
    <meta charset = "utf-8">
    <title> Admin Dashboard</title>
    <link rel = "stylesheet" href = "/style.css" />
  </head>
 <body>

  <nav id = "nav">
    <div class = "nav-link">
    <a href = "/"> Home &nbsp </a>
    </div>

    <div class = "nav-link">
    <a href = "/quotes"> Quotes &nbsp</a>
    </div>
    <div class = "nav-link">
    <a href = "/create-quote"> Create a Quote </a>
    </div>
    <span style = "float:right;" id = "logowrite">Inspiration a Day</span>
  </nav>
   
   <h1> Admin Dashboard</h1>
     <% if (await user == "sonicx180") { %>

    <p> IT WORKS!!</p>
       <% } %>
         
         <% else if (!user) { %>
           <script src="https://replit.com/public/js/repl-auth-v2.js"></script>
         <% } %>

 </body>
</html>

I was able to add a quote. Do you mean that the entire page should only be available to admins?

1 Like

What part does not work? I thought you knew how to make these lol

3 Likes

I don’t think you need to put in the await keyword. Try removing that maybe.

1 Like

Yeah, if this is flask. You don’t need any await, unless you structured your code weirdly.

1 Like

no, I mean there is something wrong with the ejs

nah, idk why I used await lol. but when u don’t use it, it still doesn’t work

We don’t know what doesn’t work means.

updated the link everyone

Yes this is broken and the last one was not.

How are you getting on with this?
The code may not be working due to the placement of the else if statement.

Try this:

<h1> Admin Dashboard</h1>
  <% if (await user == "sonicx180") { %>
    <p> IT WORKS!!</p>
  <% } else if (!user) { %>
    <script src="https://replit.com/public/js/repl-auth-v2.js"></script>
  <% } %>
1 Like

I’m so dumb, I forgot that you do that in ejs

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.