feat!: add repo searching, only show most relevant repos first

This commit is contained in:
2026-01-16 23:29:15 -08:00
parent 68d9a0a626
commit 831259a6a6
14 changed files with 174 additions and 59 deletions

View File

@@ -6,14 +6,18 @@ use jsonwebtoken::{
};
use serde::Deserialize;
pub struct UserId(pub String);
#[derive(Clone)]
pub struct User {
pub id: String,
pub name: String,
}
pub struct JWT {
reqwest_client: reqwest::Client,
}
pub trait AuthImpl {
async fn for_protected(&self, token: &str) -> Result<UserId>;
async fn for_protected(&self, token: &str) -> Result<User>;
}
pub enum Auth {
@@ -23,6 +27,7 @@ pub enum Auth {
#[derive(Deserialize)]
struct Claims {
sub: String,
name: String,
}
impl JWT {
@@ -32,7 +37,7 @@ impl JWT {
}
impl AuthImpl for JWT {
async fn for_protected(&self, token: &str) -> Result<UserId> {
async fn for_protected(&self, token: &str) -> Result<User> {
let frontend_url =
env::var("FRONTEND_BASE_URL").unwrap_or_else(|_| "http://localhost:5173".to_string());
@@ -57,12 +62,15 @@ impl AuthImpl for JWT {
_ => crate::error::Error::Unauthorized,
})?;
Ok(UserId(token_data.claims.sub))
Ok(User {
id: token_data.claims.sub,
name: token_data.claims.name,
})
}
}
impl AuthImpl for Auth {
async fn for_protected(&self, token: &str) -> Result<UserId> {
async fn for_protected(&self, token: &str) -> Result<User> {
match self {
Auth::JWT(jwt) => jwt.for_protected(token).await,
}