Fixed refresh missing email issue
This commit is contained in:
@@ -152,7 +152,7 @@ impl FromRequest for JwtAuth {
|
||||
Ok(result) => result,
|
||||
Err(_) => {
|
||||
return ready(Err(ActixError::from(ServiceError {
|
||||
status: 404,
|
||||
status: 401,
|
||||
message: format!("Access token was not found")
|
||||
})))
|
||||
}
|
||||
@@ -163,7 +163,7 @@ impl FromRequest for JwtAuth {
|
||||
ready(Ok(JwtAuth { token: access_token_uuid, user: user.into() }))
|
||||
}
|
||||
Err(_) => return ready(Err(ActixError::from(ServiceError {
|
||||
status: 404,
|
||||
status: 401,
|
||||
message: format!("User was not found")
|
||||
})))
|
||||
}
|
||||
|
||||
@@ -155,22 +155,7 @@ async fn refresh(req: HttpRequest) -> HttpResponse {
|
||||
Err(err) => return ResponseError::error_response(&err)
|
||||
};
|
||||
|
||||
let mut conn = match db::redis_async_connection().await {
|
||||
Ok(conn) => conn,
|
||||
Err(err) => {
|
||||
error!("Failed to get redis connection: {}", err);
|
||||
return ResponseError::error_response(&err)
|
||||
}
|
||||
};
|
||||
|
||||
let redis_result: redis::RedisResult<String> = conn.get(refresh_token_details.token_uuid.to_string()).await;
|
||||
let email = match redis_result {
|
||||
Ok(email) => email,
|
||||
Err(_) => return ResponseError::error_response(&ServiceError {
|
||||
status: 404,
|
||||
message: format!("Refresh token was not found")
|
||||
})
|
||||
};
|
||||
let email = refresh_token_details.email.clone();
|
||||
|
||||
match QueryUser::get_by_email(&email) {
|
||||
Ok(query_user) => {
|
||||
@@ -182,6 +167,14 @@ async fn refresh(req: HttpRequest) -> HttpResponse {
|
||||
}
|
||||
};
|
||||
|
||||
let mut conn = match db::redis_async_connection().await {
|
||||
Ok(conn) => conn,
|
||||
Err(err) => {
|
||||
error!("Failed to get redis connection: {}", err);
|
||||
return ResponseError::error_response(&err)
|
||||
}
|
||||
};
|
||||
|
||||
// Delete old auth token if it exists
|
||||
match req.cookie("access_token") {
|
||||
Some(cookie) => {
|
||||
|
||||
Reference in New Issue
Block a user