yew_oauth2/components/redirect/
location.rs1use super::{Redirect, Redirector, RedirectorProperties};
4use gloo_utils::window;
5use yew::prelude::*;
6
7pub struct LocationRedirector;
9
10impl Redirector for LocationRedirector {
11 type Properties = LocationProperties;
12
13 fn new<COMP: Component>(_: &Context<COMP>) -> Self {
14 Self {}
15 }
16
17 fn logout(&self, props: &Self::Properties) {
18 log::debug!("Navigate due to logout: {}", props.logout_href);
19 window().location().set_href(&props.logout_href).ok();
20 }
21}
22
23#[derive(Clone, Debug, PartialEq, Properties)]
24pub struct LocationProperties {
25 #[prop_or_default]
27 pub children: Html,
28
29 pub logout_href: String,
31}
32
33impl RedirectorProperties for LocationProperties {
34 fn children(&self) -> &Html {
35 &self.children
36 }
37}
38
39pub mod oauth2 {
40 use super::*;
42 use crate::agent::client::OAuth2Client as Client;
43 pub type LocationRedirect = Redirect<Client, LocationRedirector>;
44}
45
46#[cfg(feature = "openid")]
47pub mod openid {
48 use super::*;
50 use crate::agent::client::OpenIdClient as Client;
51 pub type LocationRedirect = Redirect<Client, LocationRedirector>;
52}