Moved login link logic to unauthenticated_page.rs
This commit is contained in:
1 parent
20df508ed7
commit
ade13e711f
1 file changed
+19
-5
@@ -1,20 +1,34 @@
|
|||||||
|
use leptos::leptos_dom::logging::console_log;
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos_oidc::{LoginLink};
|
use leptos_oidc::{AuthSignal};
|
||||||
use crate::components::ActionButton;
|
use crate::components::ActionButton;
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn UnauthenticatedPage() -> impl IntoView {
|
pub fn UnauthenticatedPage() -> impl IntoView {
|
||||||
|
let auth = use_context::<AuthSignal>().expect("AuthSignal not present in LoginLink");
|
||||||
|
let login_url = move || {
|
||||||
|
auth.with(|auth| {
|
||||||
|
auth.unauthenticated()
|
||||||
|
.map(|unauthenticated| unauthenticated.login_url())
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
let navigate = leptos_router::hooks::use_navigate();
|
||||||
|
|
||||||
view! (
|
view! (
|
||||||
<div class="flex h-screen justify-center items-center pb-50">
|
<div class="flex h-screen justify-center items-center pb-50">
|
||||||
<div class="bg-white p-8 border rounded-lg shadow-lg">
|
<div class="bg-white p-8 border rounded-lg shadow-lg">
|
||||||
<h3> "You're not signed in. Please sign in with your Region 15 email." </h3>
|
<h3> "You're not signed in. Please sign in with your Region 15 email." </h3>
|
||||||
<div class="flex pt-4 justify-center items-center">
|
<div class="flex pt-4 justify-center items-center">
|
||||||
<LoginLink class="text-login">
|
<ActionButton on:click=move |_| {
|
||||||
<ActionButton> "Sign in" </ActionButton>
|
if let Some(url) = login_url() {
|
||||||
</LoginLink>
|
navigate(&url, Default::default())
|
||||||
|
}
|
||||||
|
}>
|
||||||
|
"Sign in"
|
||||||
|
</ActionButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user