Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Dec 2, 2023
1 parent 04022dd commit 5546bcb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
14 changes: 9 additions & 5 deletions ee/tabby-webserver/src/schema/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -74,7 +74,7 @@ impl<S: ScalarValue> IntoFieldError<S> for RegisterError {
fn into_field_error(self) -> FieldError<S> {
match self {
Self::InvalidInput { errors } => make_field_error(errors),
_ => self.into()
_ => self.into(),
}
}
}
Expand Down Expand Up @@ -116,7 +116,7 @@ impl<S: ScalarValue> IntoFieldError<S> for TokenAuthError {
fn into_field_error(self) -> FieldError<S> {
match self {
Self::InvalidInput { errors } => make_field_error(errors),
_ => self.into()
_ => self.into(),
}
}
}
Expand Down Expand Up @@ -203,7 +203,11 @@ pub trait AuthenticationService: Send + Sync {
invitation_code: Option<String>,
) -> std::result::Result<RegisterResponse, RegisterError>;

async fn token_auth(&self, email: String, password: String) -> std::result::Result<TokenAuthResponse, TokenAuthError>;
async fn token_auth(
&self,
email: String,
password: String,
) -> std::result::Result<TokenAuthResponse, TokenAuthError>;

async fn refresh_token(&self, refresh_token: String) -> Result<RefreshTokenResponse>;
async fn verify_token(&self, access_token: String) -> Result<VerifyTokenResponse>;
Expand Down
7 changes: 3 additions & 4 deletions ee/tabby-webserver/src/service/auth.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,7 +15,6 @@ use crate::schema::{
RefreshTokenResponse, RegisterError, RegisterResponse, TokenAuthError, TokenAuthResponse,
UserInfo, VerifyTokenResponse,
},
ValidationErrors,
};

/// Input parameters for register mutation
Expand Down Expand Up @@ -287,7 +286,7 @@ mod tests {
)
.await
.unwrap();
return 1;
1
}

#[tokio::test]
Expand Down
6 changes: 3 additions & 3 deletions ee/tabby-webserver/src/service/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]";
static ADMIN_PASSWORD: &str = "123456789";
Expand Down Expand Up @@ -398,4 +398,4 @@ mod tests {
let invitations = conn.list_invitations().await.unwrap();
assert!(invitations.is_empty());
}
}
}

0 comments on commit 5546bcb

Please sign in to comment.