summaryrefslogtreecommitdiff
path: root/src/token/extract/identity.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/token/extract/identity.rs')
-rw-r--r--src/token/extract/identity.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/token/extract/identity.rs b/src/token/extract/identity.rs
index d1c0334..4d076d7 100644
--- a/src/token/extract/identity.rs
+++ b/src/token/extract/identity.rs
@@ -30,11 +30,13 @@ impl FromRequestParts<App> for Identity {
let secret = cookie.secret().ok_or(LoginError::Unauthorized)?;
let app = State::<App>::from_request_parts(parts, state).await?;
- match app.tokens().validate(&secret, &used_at).await {
- Ok((token, user)) => Ok(Identity { token, user }),
- Err(ValidateError::InvalidToken) => Err(LoginError::Unauthorized),
- Err(other) => Err(other.into()),
- }
+ app.tokens()
+ .validate(&secret, &used_at)
+ .await
+ .map_err(|err| match err {
+ ValidateError::InvalidToken => LoginError::Unauthorized,
+ other => other.into(),
+ })
}
}