use leptos::*;
use leptos_keycloak_auth::{
use_keycloak_auth, Authenticated, KeycloakAuth, UseKeycloakAuthOptions,
};
#[component]
// TODO figure out why passing children results in incorrect Fn/FnOnce type when trying to invoke
// children
pub fn Protected() -> impl IntoView {
// Note: These values should be served from environment variables to be overwritten in production.
let auth = use_keycloak_auth(UseKeycloakAuthOptions {
keycloak_server_url: "http://localhost:8081/".parse().unwrap(),
realm: "peculiar".to_owned(),
client_id: "watch".to_owned(),
post_login_redirect_url: "http://localhost:3000/".parse().unwrap(),
post_logout_redirect_url: "http://localhost:3000/".parse().unwrap(),
scope: Some("openid".to_string()),
advanced: Default::default(),
});
let user_name = Signal::derive(move || {
auth.id_token_claims
.get()
.map(|claims| claims.name.clone())
.unwrap_or_default()
});
view! {