mirror of
https://github.com/nitnelave/lldap.git
synced 2023-04-12 14:25:13 +00:00
App: Various cleanups (clippy)
This commit is contained in:
parent
c1cb5792fe
commit
ac492f987d
@ -40,7 +40,7 @@ impl Component for App {
|
||||
|
||||
fn create(_: Self::Properties, link: ComponentLink<Self>) -> Self {
|
||||
let mut app = Self {
|
||||
link: link.clone(),
|
||||
link,
|
||||
user_name: get_cookie("user_id").unwrap_or_else(|e| {
|
||||
ConsoleService::error(&e.to_string());
|
||||
None
|
||||
@ -89,7 +89,7 @@ impl Component for App {
|
||||
render = Router::render(move |switch: AppRoute| {
|
||||
match switch {
|
||||
AppRoute::Login => html! {
|
||||
<LoginForm on_logged_in=link.callback(|u| Msg::Login(u))/>
|
||||
<LoginForm on_logged_in=link.callback(Msg::Login)/>
|
||||
},
|
||||
AppRoute::Index | AppRoute::ListUsers => html! {
|
||||
<div>
|
||||
@ -112,7 +112,7 @@ impl App {
|
||||
if current_route.is_empty() || current_route.contains("login") {
|
||||
String::from("/")
|
||||
} else {
|
||||
current_route.into()
|
||||
current_route
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ fn get_document() -> Result<HtmlDocument> {
|
||||
web_sys::window()
|
||||
.map(|w| w.document())
|
||||
.flatten()
|
||||
.ok_or(anyhow!("Could not get window document"))
|
||||
.ok_or_else(|| anyhow!("Could not get window document"))
|
||||
.and_then(|d| {
|
||||
d.dyn_into::<web_sys::HtmlDocument>()
|
||||
.map_err(|_| anyhow!("Document is not an HTMLDocument"))
|
||||
@ -18,7 +18,7 @@ pub fn set_cookie(cookie_name: &str, value: &str, expiration: &DateTime<Utc>) ->
|
||||
let doc = web_sys::window()
|
||||
.map(|w| w.document())
|
||||
.flatten()
|
||||
.ok_or(anyhow!("Could not get window document"))
|
||||
.ok_or_else(|| anyhow!("Could not get window document"))
|
||||
.and_then(|d| {
|
||||
d.dyn_into::<web_sys::HtmlDocument>()
|
||||
.map_err(|_| anyhow!("Document is not an HTMLDocument"))
|
||||
@ -35,7 +35,7 @@ pub fn get_cookie(cookie_name: &str) -> Result<Option<String>> {
|
||||
.cookie()
|
||||
.map_err(|_| anyhow!("Could not access cookies"))?;
|
||||
Ok(cookies
|
||||
.split(";")
|
||||
.split(';')
|
||||
.filter_map(|c| c.split_once('='))
|
||||
.find_map(|(name, value)| {
|
||||
if name == cookie_name {
|
||||
@ -51,7 +51,7 @@ pub fn get_cookie(cookie_name: &str) -> Result<Option<String>> {
|
||||
}
|
||||
|
||||
pub fn delete_cookie(cookie_name: &str) -> Result<()> {
|
||||
if let Some(_) = get_cookie(cookie_name)? {
|
||||
if get_cookie(cookie_name)?.is_some() {
|
||||
set_cookie(cookie_name, "", &Utc.ymd(1970, 1, 1).and_hms(0, 0, 0))
|
||||
} else {
|
||||
Ok(())
|
||||
|
@ -38,7 +38,7 @@ impl Component for LoginForm {
|
||||
|
||||
fn create(props: Self::Properties, link: ComponentLink<Self>) -> Self {
|
||||
LoginForm {
|
||||
link: link.clone(),
|
||||
link,
|
||||
on_logged_in: props.on_logged_in,
|
||||
error: None,
|
||||
node_ref: NodeRef::default(),
|
||||
@ -63,8 +63,8 @@ impl Component for LoginForm {
|
||||
.unwrap()
|
||||
.value();
|
||||
let req = BindRequest {
|
||||
name: username.to_string(),
|
||||
password: password.to_string(),
|
||||
name: username,
|
||||
password,
|
||||
};
|
||||
match HostService::authenticate(
|
||||
req,
|
||||
|
@ -26,7 +26,7 @@ impl Component for LogoutButton {
|
||||
|
||||
fn create(props: Self::Properties, link: ComponentLink<Self>) -> Self {
|
||||
LogoutButton {
|
||||
link: link.clone(),
|
||||
link,
|
||||
on_logged_out: props.on_logged_out,
|
||||
_task: None,
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ impl Component for UserTable {
|
||||
|
||||
fn create(_: Self::Properties, link: ComponentLink<Self>) -> Self {
|
||||
let mut table = UserTable {
|
||||
link: link.clone(),
|
||||
link,
|
||||
_task: None,
|
||||
users: None,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user