Start work on login form
This commit is contained in:
parent
4eb3ac6350
commit
1667c3295b
4 changed files with 20 additions and 9 deletions
|
|
@ -1,16 +1,19 @@
|
|||
use axum::{
|
||||
extract::{FromRequest, Form, Json, Query},
|
||||
extract::{FromRequest, Form, Json, Query, State},
|
||||
http::{self, Request, StatusCode},
|
||||
response::{IntoResponse, Response},
|
||||
RequestExt,
|
||||
};
|
||||
use axum_typed_multipart::{TryFromMultipart, TypedMultipart};
|
||||
use yunohost_api::{Username, Password};
|
||||
|
||||
use crate::state::RoutableAppState;
|
||||
|
||||
#[derive(Debug, TryFromMultipart, Deserialize)]
|
||||
pub struct LoginForm {
|
||||
username: String,
|
||||
username: Username,
|
||||
#[allow(dead_code)]
|
||||
password: String,
|
||||
password: Password,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
|
@ -52,6 +55,10 @@ where
|
|||
}
|
||||
|
||||
#[debug_handler]
|
||||
pub async fn route(form: LoginForm) -> String {
|
||||
format!("Welcome {}", form.username)
|
||||
pub async fn route(state: State<RoutableAppState>, form: LoginForm) -> String {
|
||||
if state.check_login(&form.username, &form.password).await.unwrap() {
|
||||
format!("Welcome {}", &form.username)
|
||||
} else {
|
||||
format!("Invalid login for {}", &form.username)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue