- fix: issue where you could login if you had a valid token but an invalid session

This commit is contained in:
2025-01-08 12:37:17 -05:00
parent f4a421b7cb
commit 8c108ceeeb

View File

@@ -78,11 +78,33 @@ impl AuthService for MyAuthService {
let req = request.into_inner(); let req = request.into_inner();
match validate_token(&req.token) { match validate_token(&req.token) {
Ok(user_data) => Ok(Response::new(ValidateTokenResponse { Ok(user_data) => {
valid: true, let response = self
user_id: user_data.0, .session_client.as_ref().clone()
session_id: user_data.1, .get_session(GetSessionRequest {
})), session_id: user_data.1.clone(),
})
.await;
match response {
Ok(res) => {
debug!("Session valid: {:?}", res.into_inner());
Ok(Response::new(ValidateTokenResponse {
valid: true,
user_id: user_data.0,
session_id: user_data.1,
}))
}
Err(_) => {
debug!("Session invalid or not found");
Ok(Response::new(ValidateTokenResponse {
valid: false,
user_id: "".to_string(),
session_id: "".to_string(),
}))
}
}
},
Err(_) => Ok(Response::new(ValidateTokenResponse { Err(_) => Ok(Response::new(ValidateTokenResponse {
valid: false, valid: false,
user_id: "".to_string(), user_id: "".to_string(),