diff --git a/ee/tabby-webserver/src/schema/auth.rs b/ee/tabby-webserver/src/schema/auth.rs index 82eee961e709..30b0831b9e75 100644 --- a/ee/tabby-webserver/src/schema/auth.rs +++ b/ee/tabby-webserver/src/schema/auth.rs @@ -3,13 +3,13 @@ use std::fmt::Debug; use anyhow::Result; use async_trait::async_trait; use jsonwebtoken as jwt; -use juniper::{graphql_value, FieldError, FieldResult, GraphQLObject, IntoFieldError, ScalarValue}; +use juniper::{FieldError, GraphQLObject, IntoFieldError, ScalarValue}; use lazy_static::lazy_static; use serde::{Deserialize, Serialize}; use thiserror::Error; use validator::ValidationError; -use super::{make_field_error}; +use super::make_field_error; lazy_static! { static ref JWT_ENCODING_KEY: jwt::EncodingKey = jwt::EncodingKey::from_secret( @@ -74,7 +74,7 @@ impl IntoFieldError for RegisterError { fn into_field_error(self) -> FieldError { match self { Self::InvalidInput { errors } => make_field_error(errors), - _ => self.into() + _ => self.into(), } } } @@ -116,7 +116,7 @@ impl IntoFieldError for TokenAuthError { fn into_field_error(self) -> FieldError { match self { Self::InvalidInput { errors } => make_field_error(errors), - _ => self.into() + _ => self.into(), } } } @@ -203,7 +203,11 @@ pub trait AuthenticationService: Send + Sync { invitation_code: Option, ) -> std::result::Result; - async fn token_auth(&self, email: String, password: String) -> std::result::Result; + async fn token_auth( + &self, + email: String, + password: String, + ) -> std::result::Result; async fn refresh_token(&self, refresh_token: String) -> Result; async fn verify_token(&self, access_token: String) -> Result; diff --git a/ee/tabby-webserver/src/service/auth.rs b/ee/tabby-webserver/src/service/auth.rs index 024ab5622c3a..fd6a4e388ec7 100644 --- a/ee/tabby-webserver/src/service/auth.rs +++ b/ee/tabby-webserver/src/service/auth.rs @@ -1,11 +1,11 @@ -use anyhow::{ensure, Result}; +use anyhow::{Result}; use argon2::{ password_hash, password_hash::{rand_core::OsRng, SaltString}, Argon2, PasswordHasher, PasswordVerifier, }; use async_trait::async_trait; -use juniper::{FieldResult, IntoFieldError}; + use validator::Validate; use super::db::DbConn; @@ -15,7 +15,6 @@ use crate::schema::{ RefreshTokenResponse, RegisterError, RegisterResponse, TokenAuthError, TokenAuthResponse, UserInfo, VerifyTokenResponse, }, - ValidationErrors, }; /// Input parameters for register mutation @@ -287,7 +286,7 @@ mod tests { ) .await .unwrap(); - return 1; + 1 } #[tokio::test] diff --git a/ee/tabby-webserver/src/service/db.rs b/ee/tabby-webserver/src/service/db.rs index fc6429ee08ec..a05667019828 100644 --- a/ee/tabby-webserver/src/service/db.rs +++ b/ee/tabby-webserver/src/service/db.rs @@ -309,10 +309,10 @@ impl DbConn { #[cfg(test)] mod tests { - use assert_matches::assert_matches; + use super::*; - use crate::schema::auth::{AuthenticationService, RegisterError, TokenAuthError}; + use crate::schema::auth::{AuthenticationService}; static ADMIN_EMAIL: &str = "test@example.com"; static ADMIN_PASSWORD: &str = "123456789"; @@ -398,4 +398,4 @@ mod tests { let invitations = conn.list_invitations().await.unwrap(); assert!(invitations.is_empty()); } -} \ No newline at end of file +}