Skip to content

Commit

Permalink
resolve comments
Browse files Browse the repository at this point in the history
  • Loading branch information
darknight committed Nov 29, 2023
1 parent 821db3b commit 03e0a6f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ee/tabby-webserver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ homepage.workspace = true
anyhow.workspace = true
argon2 = "0.5.1"
async-trait.workspace = true
axum = { workspace = true, features = ["ws", "headers"] }
axum = { workspace = true, features = ["ws"] }
bincode = "1.3.3"
chrono = "0.4"
futures.workspace = true
Expand Down
13 changes: 6 additions & 7 deletions ee/tabby-webserver/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ lazy_static! {
]);
}

#[derive(Debug, Default)]
pub struct User {
created_at: String,
updated_at: String,
_created_at: String,
_updated_at: String,

pub id: u32,
pub username: String,
Expand Down Expand Up @@ -169,8 +168,8 @@ impl DbConn {
email: row.get(2)?,
password_encrypted: row.get(3)?,
is_admin: row.get(4)?,
created_at: row.get(5)?,
updated_at: row.get(6)?,
_created_at: row.get(5)?,
_updated_at: row.get(6)?,
})
},
).optional()
Expand All @@ -195,8 +194,8 @@ impl DbConn {
email: row.get(2)?,
password_encrypted: row.get(3)?,
is_admin: row.get(4)?,
created_at: row.get(5)?,
updated_at: row.get(6)?,
_created_at: row.get(5)?,
_updated_at: row.get(6)?,
})
},
).optional()
Expand Down
3 changes: 1 addition & 2 deletions ee/tabby-webserver/src/schema/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ pub struct TokenAuthResponse {
access_token: String,
refresh_token: String,
errors: Vec<AuthError>,
// user: UserResponse,
}

impl TokenAuthResponse {
Expand Down Expand Up @@ -145,7 +144,7 @@ impl VerifyTokenResponse {
}
}

#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, GraphQLObject)]
#[derive(Debug, Default, Serialize, Deserialize, GraphQLObject)]
pub struct UserInfo {
username: String,
is_admin: bool,
Expand Down
14 changes: 7 additions & 7 deletions ee/tabby-webserver/src/server/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct RegisterInput {
#[validate(length(
min = 4,
"username_too_short",
message = "Username must be at least 8 characters"
message = "Username must be at least 4 characters"
))]
#[validate(length(
max = 20,
Expand Down Expand Up @@ -88,7 +88,7 @@ pub struct TokenAuthInput {
#[validate(length(
min = 4,
"username_too_short",
message = "Username must be at least 8 characters"
message = "Username must be at least 4 characters"
))]
#[validate(length(
max = 20,
Expand Down Expand Up @@ -184,7 +184,7 @@ impl AuthenticationService for DbConn {
}
};

// FIXME: generate refresh token
// TODO: generate refresh token

let resp = RegisterResponse::new(access_token, "".to_string());
Ok(resp)
Expand Down Expand Up @@ -242,15 +242,15 @@ impl AuthenticationService for DbConn {
}
};

// FIXME: generate refresh token
// TODO: generate refresh token

let resp = TokenAuthResponse::new(access_token, "".to_string());
Ok(resp)
}

// FIXME: implement refresh token
// TODO: implement refresh token
async fn refresh_token(&self, _refresh_token: String) -> Result<RefreshTokenResponse> {
unimplemented!()
todo!()
}

async fn verify_token(&self, access_token: String) -> Result<VerifyTokenResponse> {
Expand Down Expand Up @@ -330,6 +330,6 @@ mod tests {
let claims = Claims::new(UserInfo::new("test".to_string(), false));
let token = generate_jwt(claims).unwrap();
let claims = validate_jwt(&token).unwrap();
assert_eq!(claims.user, UserInfo::new("test".to_string(), false));
assert_eq!(claims.user_info(), UserInfo::new("test".to_string(), false));

Check failure on line 333 in ee/tabby-webserver/src/server/auth.rs

View workflow job for this annotation

GitHub Actions / autofix

binary operation `==` cannot be applied to type `schema::auth::UserInfo`
}
}

0 comments on commit 03e0a6f

Please sign in to comment.