- fix: issue where you could login if you had a valid token but an invalid session
This commit is contained in:
@@ -78,11 +78,33 @@ impl AuthService for MyAuthService {
|
||||
let req = request.into_inner();
|
||||
|
||||
match validate_token(&req.token) {
|
||||
Ok(user_data) => Ok(Response::new(ValidateTokenResponse {
|
||||
valid: true,
|
||||
user_id: user_data.0,
|
||||
session_id: user_data.1,
|
||||
})),
|
||||
Ok(user_data) => {
|
||||
let response = self
|
||||
.session_client.as_ref().clone()
|
||||
.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 {
|
||||
valid: false,
|
||||
user_id: "".to_string(),
|
||||
|
||||
Reference in New Issue
Block a user