Fix more clippy warnings
All checks were successful
Build Crate / build (push) Successful in 1m45s

This commit is contained in:
2024-08-28 23:54:56 -04:00
parent aca0b83dd4
commit d6e62b98aa
5 changed files with 23 additions and 15 deletions

View File

@@ -95,7 +95,7 @@ fn login_form_capsule<G: Html>(
#[cfg(client)] #[cfg(client)]
{ {
spawn_local_scoped(cx, async move { spawn_local_scoped(cx, async move {
let remember_me = state.remember_me.get().as_ref().clone(); let remember_me = *state.remember_me.get().as_ref();
let username = state.username.get().as_ref().clone(); let username = state.username.get().as_ref().clone();
let login_info = LoginInfo { let login_info = LoginInfo {
username: username.clone(), username: username.clone(),

View File

@@ -47,7 +47,7 @@ impl AuthDataRx {
// Save token to session storage // Save token to session storage
self.username.set(Some(auth_info.username.clone())); self.username.set(Some(auth_info.username.clone()));
self.remember_me.set(Some(auth_info.remember_me.clone())); self.remember_me.set(Some(auth_info.remember_me));
self.auth_info.set(Some(auth_info)); self.auth_info.set(Some(auth_info));
self.state.set(LoginState::Authenticated); self.state.set(LoginState::Authenticated);
} }

View File

@@ -99,11 +99,13 @@ pub async fn post_test_login(
if auth_header_str.starts_with("Bearer ") { if auth_header_str.starts_with("Bearer ") {
let token = auth_header_str.trim_start_matches("Bearer ").to_string(); let token = auth_header_str.trim_start_matches("Bearer ").to_string();
// @todo change secret // @todo change secret
if let Ok(_) = decode::<Claims>( if decode::<Claims>(
&token, &token,
&DecodingKey::from_secret("secret".as_ref()), &DecodingKey::from_secret("secret".as_ref()),
&Validation::default(), &Validation::default(),
) { )
.is_ok()
{
return Ok(Json("Logged in".to_owned())); return Ok(Json("Logged in".to_owned()));
} }
} }

View File

@@ -51,7 +51,7 @@ pub async fn post_register_user(
username: Set(username), username: Set(username),
password_hash_and_salt: Set(phc_string), password_hash_and_salt: Set(phc_string),
nickname: Set({ nickname: Set({
if register_info.nickname == "" { if register_info.nickname.is_empty() {
None None
} else { } else {
Some(register_info.nickname) Some(register_info.nickname)
@@ -61,7 +61,7 @@ pub async fn post_register_user(
last_active_time: Set(Utc::now().naive_utc()), last_active_time: Set(Utc::now().naive_utc()),
is_admin: Set(false), is_admin: Set(false),
email: Set({ email: Set({
if register_info.email == "" { if register_info.email.is_empty() {
None None
} else { } else {
Some(register_info.email) Some(register_info.email)
@@ -82,5 +82,5 @@ pub async fn post_register_user(
} }
}; };
return (StatusCode::OK, Json(GenericResponse::ok())); (StatusCode::OK, Json(GenericResponse::ok()))
} }

View File

@@ -1,3 +1,5 @@
use std::fmt::Display;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone)] #[derive(Serialize, Deserialize, Clone)]
@@ -15,14 +17,18 @@ pub enum GameState {
TableTennis, TableTennis,
} }
impl ToString for GameState { impl Display for GameState {
fn to_string(&self) -> String { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"{}",
match self { match self {
GameState::None => String::new(), GameState::None => "",
GameState::Pool => "Pool".to_owned(), GameState::Pool => "Pool",
GameState::Pickleball => "Pool".to_owned(), GameState::Pickleball => "Pickle Ball",
GameState::TableTennis => "Pool".to_owned(), GameState::TableTennis => "Table Tennis",
} }
)
} }
} }