Creating the View Template
We need to create one new template to that will display the login page:
<!--login.html-->
{{ template "header.html" .}}
<h1>Login</h1>
<div class="panel panel-default col-sm-6">
<div class="panel-body">
{{ if .ErrorTitle}}
<p class="bg-danger">
{{.ErrorTitle}}: {{.ErrorMessage}}
</p>
{{end}}
<form class="form" action="/u/login" method="POST">
<div class="form-group">
<label for="username">Username</label>
<input type="text" class="form-control" id="username" name="username" placeholder="Username">
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" class="form-control" id="password" name="password" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
</div>
</div>
{{ template "footer.html" .}}
Additionally, we also need to modify the menu.html
template to display the login and logout links, as follows:
<!--menu.html-->
.
.
<ul class="nav navbar-nav">
<li><a href="/u/register">Register</a></li>
<li><a href="/u/login">Login</a></li>
<li><a href="/u/logout">Logout</a></li>
</ul>
.
.