Redirect to login. Login view
This commit is contained in:
parent
759d271111
commit
330b6bdd4f
@ -1,17 +1,25 @@
|
||||
use maud::Markup;
|
||||
use rocket::http::Status;
|
||||
use rocket::{http::Status, response::Redirect};
|
||||
|
||||
mod utils;
|
||||
|
||||
|
||||
#[get("/")]
|
||||
pub fn homepage() -> Markup {
|
||||
crate::view::homepage()
|
||||
}
|
||||
|
||||
#[get("/new")]
|
||||
pub fn new_definition(user: utils::User) -> (Status, Markup) {
|
||||
|
||||
pub fn new_definition(_user: utils::User) -> (Status, Markup) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[get("/new", rank = 2)]
|
||||
pub fn new_definition_redirect() -> Redirect {
|
||||
println!("carita feliz :D");
|
||||
Redirect::to("/login")
|
||||
}
|
||||
|
||||
#[get("/login")]
|
||||
pub fn login_page() -> Markup {
|
||||
crate::view::login::login()
|
||||
}
|
||||
|
@ -6,8 +6,7 @@ use rocket::{
|
||||
/// Name of the header that stores the session ID of an user
|
||||
const RS_SESSION_ID: &str = "x-rs-session-id";
|
||||
|
||||
pub struct User {
|
||||
}
|
||||
pub struct User {}
|
||||
|
||||
#[rocket::async_trait]
|
||||
impl<'r> FromRequest<'r> for User {
|
||||
@ -18,7 +17,7 @@ impl<'r> FromRequest<'r> for User {
|
||||
|
||||
let _session_cookie = match session_cookie {
|
||||
Some(cookie) => cookie.value().to_string(),
|
||||
None => return Outcome::Error((Status::Unauthorized, "Unauthorized".into())),
|
||||
None => return Outcome::Forward(Status::Unauthorized),
|
||||
};
|
||||
|
||||
// Check if session cookie is valid
|
||||
|
10
src/main.rs
10
src/main.rs
@ -9,6 +9,14 @@ use rocket::fs::{relative, FileServer};
|
||||
#[launch]
|
||||
fn rocket() -> _ {
|
||||
rocket::build()
|
||||
.mount("/", routes![controller::homepage, controller::new_definition])
|
||||
.mount(
|
||||
"/",
|
||||
routes![
|
||||
controller::homepage,
|
||||
controller::new_definition,
|
||||
controller::new_definition_redirect,
|
||||
controller::login_page,
|
||||
],
|
||||
)
|
||||
.mount("/static", FileServer::from(relative!("static")))
|
||||
}
|
||||
|
37
src/view/login.rs
Normal file
37
src/view/login.rs
Normal file
@ -0,0 +1,37 @@
|
||||
use maud::{html, Markup};
|
||||
|
||||
use super::skeleton;
|
||||
|
||||
pub fn login() -> Markup {
|
||||
skeleton(html! {
|
||||
h1 class="text-3xl font-bold text-center my-4 fixed top-0 w-screen" {
|
||||
"Jerguero"
|
||||
}
|
||||
div class="flex items-center h-screen w-full" {
|
||||
div class="container mx-auto" {
|
||||
p class="my-4 p-2 rounded bg-c-bg-2 text-c-on-bg" {
|
||||
"¡Iniciá sesión para comenzar a crear definiciones!"
|
||||
}
|
||||
div class="my-4 py-4 px-2 rounded bg-c-bg-2 text-c-on-bg" {
|
||||
div class="py-2" {
|
||||
label class="text-sm opacity-85" for="login-email" {"Correo electronico:"}
|
||||
br;
|
||||
input class="inline-block w-full rounded bg-c-bg text-c-on-bg py-2 px-1" id="login-email";
|
||||
}
|
||||
|
||||
div class="py-2" {
|
||||
label class="text-sm opacity-85" for="login-password" {"Contraseña:"}
|
||||
br;
|
||||
input class="inline-block w-full rounded bg-c-bg text-c-on-bg py-2 px-1" id="login-password";
|
||||
}
|
||||
|
||||
div class="text-center pt-2" {
|
||||
button type="submit" class="py-1 px-2 rounded bg-c-primary text-c-on-primary hover:underline" {
|
||||
"Iniciar sesión"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
use maud::{html, Markup, DOCTYPE};
|
||||
|
||||
mod icons;
|
||||
pub mod login;
|
||||
|
||||
use icons::{bird, magnifying_glass};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user