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

derive identity error impls

This commit is contained in:
Rob Ede
2023-01-07 02:22:13 +00:00
parent 1ed893a08c
commit 441d604c00
3 changed files with 30 additions and 111 deletions

View File

@ -9,7 +9,9 @@ use actix_web::{
use crate::{
config::LogoutBehaviour,
error::{GetIdentityError, LoginError, LostIdentityError, MissingIdentityError},
error::{
GetIdentityError, LoginError, LostIdentityError, MissingIdentityError, SessionExpiryError,
},
};
/// A verified user identity. It can be used as a request extractor.
@ -212,7 +214,8 @@ impl Identity {
.session
.get(LOGIN_UNIX_TIMESTAMP_KEY)?
.map(OffsetDateTime::from_unix_timestamp)
.transpose()?)
.transpose()
.map_err(SessionExpiryError)?)
}
pub(crate) fn last_visited_at(&self) -> Result<Option<OffsetDateTime>, GetIdentityError> {
@ -221,7 +224,8 @@ impl Identity {
.session
.get(LAST_VISIT_UNIX_TIMESTAMP_KEY)?
.map(OffsetDateTime::from_unix_timestamp)
.transpose()?)
.transpose()
.map_err(SessionExpiryError)?)
}
pub(crate) fn set_last_visited_at(&self) -> Result<(), LoginError> {