fight unuseds, sessions endpoint
This commit is contained in:
@@ -10,7 +10,7 @@ use crate::{
|
||||
ISE_MSG,
|
||||
database::{self},
|
||||
users::{
|
||||
auth::{AuthError, UserPasswordHashing},
|
||||
auth::UserPasswordHashing,
|
||||
handle::{UserHandle, UserHandleError},
|
||||
},
|
||||
};
|
||||
@@ -122,6 +122,7 @@ impl User {
|
||||
/// to do everything and probably should not be used as a regular account
|
||||
/// due to the ramifications of compromise. But it could be used for that,
|
||||
/// and have its name changed.
|
||||
#[allow(unused)]
|
||||
pub fn is_infradmin(&self) -> bool {
|
||||
self.id == Uuid::max()
|
||||
}
|
||||
@@ -167,6 +168,7 @@ impl User {
|
||||
/// for actions performed by Mnemosyne internally.
|
||||
/// It shall not be available for log-in.
|
||||
/// It should not have its name changed, and should be protected from that.
|
||||
#[allow(unused)]
|
||||
pub fn is_systemuser(&self) -> bool {
|
||||
self.id == Uuid::nil()
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ impl Session {
|
||||
None => Err(SessionError::NoSessionWithToken(token.to_string())),
|
||||
}
|
||||
}
|
||||
#[allow(unused)]
|
||||
pub fn new_for_user(user: &User) -> Result<(Session, String), SessionError> {
|
||||
let id = Uuid::now_v7();
|
||||
let token = auth::generate_token(auth::TokenSize::Char64);
|
||||
@@ -139,6 +140,7 @@ impl Session {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn revoke(&mut self, actor: Option<&User>) -> Result<(), SessionError> {
|
||||
let now = Utc::now();
|
||||
let id = actor.map(|u| u.id).unwrap_or(Uuid::nil());
|
||||
@@ -154,6 +156,7 @@ impl Session {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn issued(&self) -> DateTime<Utc> {
|
||||
// unwrapping here since we use UUIDv7
|
||||
// and since we assume we're not in 10k CE
|
||||
|
||||
Reference in New Issue
Block a user