Implementing the login View

For the login view, Listing 26.12 implements a simple login form that allows you to specify a username and password to use to create an authenticated session. The form includes text and password <input> elements. The form method is POST, to include the username and password fields in the POST body for the route. Notice that the <%=msg> EJS script element is included to display the message if one exists on the session. Figure 26.3 shows the rendered login page.

Listing 26.12 login.html: Implementing the login EJS HTML template


01 <!doctype html>
02 <html>
03 <head>
04   <title>User Login and Sessions</title>
05   <link rel="stylesheet" type="text/css"
06         href="/static/css/styles.css" />
07 </head>
08 <body>
09   <div class="form-container">
10     <p class="form-header">Login</p>
11     <form method="POST">
12         <label>Username:</label>
13         <input type="text" name="username"><br>
14         <label>Password:</label>
15         <input type="password" name="password"><br>
16         <input type="submit" value="Login">
17     </form>
18   </div>
19   <a href="/signup">Sign Up</a>
20   <hr><%= msg %>
21 </body>
22 </html>


Image

Figure 26.3 The rendered login view allows you to log in to the server.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.20.133