1
0
mirror of https://github.com/actix/examples synced 2025-06-27 01:27:43 +02:00

reduce futures dep

This commit is contained in:
Rob Ede
2022-03-06 00:15:16 +00:00
parent c5f2a8fcc7
commit e8cd22d2f2
25 changed files with 62 additions and 59 deletions

View File

@ -1,8 +1,9 @@
use std::future::{ready, Ready};
use actix_identity::Identity;
use actix_web::{dev::Payload, web, Error, FromRequest, HttpRequest, HttpResponse};
use diesel::prelude::*;
use diesel::PgConnection;
use futures::future::{err, ok, Ready};
use serde::Deserialize;
use crate::errors::ServiceError;
@ -27,11 +28,12 @@ impl FromRequest for LoggedUser {
if let Ok(identity) = Identity::from_request(req, pl).into_inner() {
if let Some(user_json) = identity.identity() {
if let Ok(user) = serde_json::from_str(&user_json) {
return ok(user);
return ready(Ok(user));
}
}
}
err(ServiceError::Unauthorized.into())
ready(Err(ServiceError::Unauthorized.into()))
}
}