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:
parent
fd1479edcd
commit
9eaf121454
11
src/main.rs
11
src/main.rs
|
@ -109,6 +109,16 @@ struct LoginData {
|
|||
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>")]
|
||||
fn login(form_data: Form<LoginData>) -> String {
|
||||
let auth = BasicAuthentication {
|
||||
|
@ -188,6 +198,7 @@ fn routes() -> Vec<rocket::Route> {
|
|||
oidc_config,
|
||||
get_keys,
|
||||
login,
|
||||
login_form,
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,6 @@
|
|||
{% 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>
|
||||
<h1>Hello?</h1>
|
||||
<a href="/login">Login</a>
|
||||
{% endblock content %}
|
||||
|
|
|
@ -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 %}
|
Loading…
Reference in New Issue