Prevent crash from occuring
This commit is contained in:
parent
8cdb47a139
commit
deb00c572d
@ -6,6 +6,7 @@ use actix::Addr;
|
|||||||
use actix_identity::Identity;
|
use actix_identity::Identity;
|
||||||
use actix_web::{Error, FromRequest, HttpRequest, web};
|
use actix_web::{Error, FromRequest, HttpRequest, web};
|
||||||
use actix_web::dev::Payload;
|
use actix_web::dev::Payload;
|
||||||
|
use actix_web::error::ErrorInternalServerError;
|
||||||
|
|
||||||
use crate::actors::users_actor;
|
use crate::actors::users_actor;
|
||||||
use crate::actors::users_actor::UsersActor;
|
use crate::actors::users_actor::UsersActor;
|
||||||
@ -41,9 +42,14 @@ impl FromRequest for CurrentUser {
|
|||||||
|
|
||||||
|
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
let user: User = user_actor.send(
|
let user = match user_actor.send(
|
||||||
users_actor::GetUserRequest(user_id)
|
users_actor::GetUserRequest(user_id)
|
||||||
).await.unwrap().0.unwrap();
|
).await.unwrap().0 {
|
||||||
|
Some(u) => u,
|
||||||
|
None => {
|
||||||
|
return Err(ErrorInternalServerError("Could not extract user information!"));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Ok(CurrentUser(user))
|
Ok(CurrentUser(user))
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user