Adding route for login and login_form

The EmptyContext is probably dumb or at least goofy.. but I can't work
out a better way of making render() happy right now.
This commit is contained in:
Alex Wright 2020-02-29 20:23:48 +01:00
parent fd1479edcd
commit 9eaf121454
3 changed files with 36 additions and 19 deletions

View File

@ -109,6 +109,16 @@ struct LoginData {
password: String, password: String,
} }
#[derive(Serialize)]
struct EmptyContext {
}
#[get("/login")]
fn login_form() -> Template {
let context = EmptyContext {};
Template::render("login_form", &context)
}
#[post("/login", data = "<form_data>")] #[post("/login", data = "<form_data>")]
fn login(form_data: Form<LoginData>) -> String { fn login(form_data: Form<LoginData>) -> String {
let auth = BasicAuthentication { let auth = BasicAuthentication {
@ -188,6 +198,7 @@ fn routes() -> Vec<rocket::Route> {
oidc_config, oidc_config,
get_keys, get_keys,
login, login,
login_form,
] ]
} }

View File

@ -1,23 +1,6 @@
{% extends "base" %} {% extends "base" %}
{% block content %} {% block content %}
<h1>Login</h1> <h1>Hello?</h1>
<form action="/login" method="POST"> <a href="/login">Login</a>
<fieldset>
<legend>Login</legend>
<div class="form-group">
<label for="username">Username:</label>
<input type="text" name="username">
<label for="username"><abbr title="required" aria-label="required">*</abbr></label>
</div>
<div class="form-group">
<label for="password">Username:</label>
<input type="password" name="password">
<label for="password"><abbr title="required" aria-label="required">*</abbr></label>
</div>
<div class="form-group">
<button type="submit">Login</button>
</div>
</fieldset>
</form>
{% endblock content %} {% endblock content %}

View File

@ -0,0 +1,23 @@
{% extends "base" %}
{% block content %}
<h1>Login</h1>
<form action="/login" method="POST">
<fieldset>
<legend>Login</legend>
<div class="form-group">
<label for="username">Username:</label>
<input type="text" name="username">
<label for="username"><abbr title="required" aria-label="required">*</abbr></label>
</div>
<div class="form-group">
<label for="password">Username:</label>
<input type="password" name="password">
<label for="password"><abbr title="required" aria-label="required">*</abbr></label>
</div>
<div class="form-group">
<button type="submit">Login</button>
</div>
</fieldset>
</form>
{% endblock content %}