Browse Source

change bid substring to colon delimiter

feature/better-mod-tooling
DashEightMate 1 year ago
parent
commit
59aad118eb
  1. 10
      server/src/api/mod.rs
  2. 2
      server/src/api/user.rs

10
server/src/api/mod.rs

@ -71,14 +71,10 @@ pub(in crate::api) async fn get_user_from_jwt(
jwt: &str,
pool: &DbPool,
) -> Result<User_, LemmyError> {
let (jwt_spliced, bid_str) = if jwt.len() >= 192 {
jwt.split_at(192)
} else {
(jwt, "")
};
let mut bid_string = bid_str.to_string();
let jwt_split = jwt.split(":").collect::<Vec<_>>();
let mut bid_string = jwt_split.get(1).unwrap_or(&"").to_string();
let claims = match Claims::decode(&jwt_spliced) {
let claims = match Claims::decode(&jwt_split[0]) {
Ok(claims) => claims.claims,
Err(_e) => return Err(APIError::err("not_logged_in").into()),
};

2
server/src/api/user.rs

@ -227,7 +227,7 @@ impl Perform for Login {
let jwt = generate_token(context, user.id).await?;
Ok(LoginResponse {
requires_2fa: false,
jwt: format!("{}{}", jwt.token_hash, bid),
jwt: format!("{}:{}", jwt.token_hash, bid),
})
}
}

Loading…
Cancel
Save