add signup page
This commit is contained in:
parent
c75bd0cb31
commit
30f8d9ecf1
2 changed files with 34 additions and 2 deletions
|
@ -8,7 +8,7 @@ use axum::{
|
|||
extract::State,
|
||||
http::StatusCode,
|
||||
response::{IntoResponse, Redirect},
|
||||
routing::{get, post},
|
||||
routing::get,
|
||||
Form, Router,
|
||||
};
|
||||
use password_hash::{rand_core::OsRng, PasswordHash, PasswordHasher, PasswordVerifier, SaltString};
|
||||
|
@ -23,11 +23,24 @@ use crate::server::{
|
|||
|
||||
pub fn build() -> Router<AppState> {
|
||||
Router::new()
|
||||
.route("/signup", post(signup))
|
||||
.route("/signup", get(signup_page).post(signup))
|
||||
.route("/login", get(login_page).post(login))
|
||||
.route("/logout", get(logout_page).post(logout))
|
||||
}
|
||||
|
||||
#[derive(Template, WebTemplate, Default)]
|
||||
#[template(path = "signup.html")]
|
||||
struct SignupPage {
|
||||
error: Option<String>,
|
||||
}
|
||||
|
||||
#[tracing::instrument]
|
||||
pub async fn signup_page() -> SignupPage {
|
||||
info!("get signup page");
|
||||
|
||||
SignupPage::default()
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct SignupForm {
|
||||
email: String,
|
||||
|
|
19
templates/signup.html
Normal file
19
templates/signup.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<title>Signup</title>
|
||||
{%if let Some(msg) = error %}
|
||||
<p class="error">{{msg}}</p>
|
||||
{% endif %}
|
||||
<form method=post>
|
||||
<label>
|
||||
Email Address
|
||||
<input type=text name=email>
|
||||
</label>
|
||||
<label>
|
||||
Password
|
||||
<input type=password name=password>
|
||||
</label>
|
||||
|
||||
<button type="submit">Signup</button>
|
||||
</form>
|
||||
</html>
|
Loading…
Add table
Reference in a new issue