1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-07-01 04:05:09 +02:00

migrate to actix-web beta 14 (#209)

This commit is contained in:
Rob Ede
2021-12-11 16:05:21 +00:00
committed by GitHub
parent 700d90b68b
commit 74ec115161
27 changed files with 134 additions and 128 deletions

View File

@ -1,8 +1,8 @@
use actix_utils::future::{ready, Ready};
use actix_web::{
dev::{Extensions, Payload},
Error, FromRequest, HttpRequest,
};
use actix_utils::future::{ready, Ready};
pub(crate) struct IdentityItem {
pub(crate) id: Option<String>,
@ -48,12 +48,12 @@ impl Identity {
/// Return the claimed identity of the user associated request or `None` if no identity can be
/// found associated with the request.
pub fn identity(&self) -> Option<String> {
Identity::get_identity(&self.0.extensions())
Identity::get_identity(&self.0.req_data())
}
/// Remember identity.
pub fn remember(&self, identity: String) {
if let Some(id) = self.0.extensions_mut().get_mut::<IdentityItem>() {
if let Some(id) = self.0.req_data_mut().get_mut::<IdentityItem>() {
id.id = Some(identity);
id.changed = true;
}
@ -61,7 +61,7 @@ impl Identity {
/// This method is used to 'forget' the current identity on subsequent requests.
pub fn forget(&self) {
if let Some(id) = self.0.extensions_mut().get_mut::<IdentityItem>() {
if let Some(id) = self.0.req_data_mut().get_mut::<IdentityItem>() {
id.id = None;
id.changed = true;
}