Can configure maximum inactivity of token
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
2024-04-19 18:52:28 +02:00
parent 89b9f7c292
commit ec25b6e4f1
2 changed files with 24 additions and 9 deletions

View File

@ -159,7 +159,7 @@ pub struct NewToken {
pub description: String,
pub rights: TokenRights,
pub ip_restriction: Option<ipnetwork::IpNetwork>,
pub delete_after_inactivity: Option<u64>,
pub max_inactivity: Option<u64>,
}
impl NewToken {
@ -185,7 +185,7 @@ impl NewToken {
return Some(err);
}
if let Some(t) = self.delete_after_inactivity {
if let Some(t) = self.max_inactivity {
if t < 3600 {
return Some("API tokens shall be valid for at least 1 hour!");
}
@ -209,7 +209,7 @@ pub async fn create(t: &NewToken) -> anyhow::Result<(Token, TokenPrivKey)> {
rights: t.rights.clone(),
last_used: time(),
ip_restriction: t.ip_restriction,
max_inactivity: t.delete_after_inactivity,
max_inactivity: t.max_inactivity,
};
token.save()?;