This commit is contained in:
@@ -128,21 +128,21 @@ impl FromRequest for ApiAuthExtractor {
|
||||
));
|
||||
}
|
||||
|
||||
if let Some(ip) = token.ip_restriction {
|
||||
if !ip.contains(remote_ip.0) {
|
||||
log::error!(
|
||||
"Attempt to use a token for an unauthorized IP! {remote_ip:?} token_id={}",
|
||||
token.id.0
|
||||
);
|
||||
return Err(ErrorUnauthorized("Token cannot be used from this IP!"));
|
||||
}
|
||||
if let Some(ip) = token.ip_restriction
|
||||
&& !ip.contains(remote_ip.0)
|
||||
{
|
||||
log::error!(
|
||||
"Attempt to use a token for an unauthorized IP! {remote_ip:?} token_id={}",
|
||||
token.id.0
|
||||
);
|
||||
return Err(ErrorUnauthorized("Token cannot be used from this IP!"));
|
||||
}
|
||||
|
||||
if token.should_update_last_activity() {
|
||||
if let Err(e) = api_tokens::refresh_last_used(token.id).await {
|
||||
log::error!("Could not update token last activity! {e}");
|
||||
return Err(ErrorBadRequest("Couldn't refresh token last activity!"));
|
||||
}
|
||||
if token.should_update_last_activity()
|
||||
&& let Err(e) = api_tokens::refresh_last_used(token.id).await
|
||||
{
|
||||
log::error!("Could not update token last activity! {e}");
|
||||
return Err(ErrorBadRequest("Couldn't refresh token last activity!"));
|
||||
}
|
||||
|
||||
Ok(ApiAuthExtractor { token, claims })
|
||||
|
Reference in New Issue
Block a user