use super::{Redirect, Redirector, RedirectorProperties};
use gloo_utils::window;
use yew::prelude::*;
pub struct LocationRedirector;
impl Redirector for LocationRedirector {
type Properties = LocationProperties;
fn new<COMP: Component>(_: &Context<COMP>) -> Self {
Self {}
}
fn logout(&self, props: &Self::Properties) {
log::debug!("Navigate due to logout: {}", props.logout_href);
window().location().set_href(&props.logout_href).ok();
}
}
#[derive(Clone, Debug, PartialEq, Properties)]
pub struct LocationProperties {
#[prop_or_default]
pub children: Html,
pub logout_href: String,
}
impl RedirectorProperties for LocationProperties {
fn children(&self) -> &Html {
&self.children
}
}
pub mod oauth2 {
use super::*;
use crate::agent::client::OAuth2Client as Client;
pub type LocationRedirect = Redirect<Client, LocationRedirector>;
}
#[cfg(feature = "openid")]
pub mod openid {
use super::*;
use crate::agent::client::OpenIdClient as Client;
pub type LocationRedirect = Redirect<Client, LocationRedirector>;
}