(req: &HttpRequest, pl: &mut Payload)
| 28 | type Future = Ready<Result<LoggedUser, Error>>; |
| 29 | |
| 30 | fn from_request(req: &HttpRequest, pl: &mut Payload) -> Self::Future { |
| 31 | if let Ok(identity) = Identity::from_request(req, pl).into_inner() |
| 32 | && let Ok(user_json) = identity.id() |
| 33 | && let Ok(user) = serde_json::from_str(&user_json) |
| 34 | { |
| 35 | return ready(Ok(user)); |
| 36 | } |
| 37 | |
| 38 | ready(Err(ServiceError::Unauthorized.into())) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | pub async fn logout(id: Identity) -> HttpResponse { |
| 43 | id.logout(); |