diff --git a/src/main.rs b/src/main.rs index a8b05da..31fd54c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,6 +31,9 @@ use ldap3::{ LdapConn, Scope, SearchEntry }; use rocket::request::{ FlashMessage, Form, + FromRequest, + Outcome, + Request, }; use rocket::response::{ Flash, @@ -220,12 +223,32 @@ fn oidc_config() -> Json { Json(config) } +impl<'a, 'r> FromRequest<'a, 'r> for User { + type Error = (); + + fn from_request(_request: &'a Request<'r>) -> Outcome { + Outcome::Success(User { + id: 1, + username: "Alex".to_string(), + is_active: true, + created_at: None, + updated_at: None, + }) + } +} + +#[derive(Serialize)] +struct HelloContext { + username: String, +} + #[get("/")] -fn hello() -> Template { - let config = OidcConfig { - jwks_uri: "https://auth.xeen.dev/oauth2/keys".to_string(), +fn hello(user: User) -> Template { + println!("User: {:?}", &user); + let context = HelloContext { + username: user.username, }; - Template::render("hello", &config) + Template::render("hello", &context) } fn routes() -> Vec {