feat: impl interface to check if user exists for publiccode
This commit is contained in:
parent
e2cf9460e5
commit
2ebd53e612
1 changed files with 11 additions and 0 deletions
|
@ -152,6 +152,17 @@ impl Federate for PccFederate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// check if an user exists.
|
||||||
|
async fn user_exists(&self, username: &str, hostname: &str) -> Result<bool, Self::Error> {
|
||||||
|
let path = self.get_user_path(username, hostname, false).await?;
|
||||||
|
if path.exists() && path.is_dir() {
|
||||||
|
let user = path.join(USER_INFO_FILE);
|
||||||
|
Ok(user.exists() && user.is_file())
|
||||||
|
} else {
|
||||||
|
Ok(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// create user isntance
|
/// create user isntance
|
||||||
async fn create_user(&self, f: &AddUser<'_>) -> Result<(), Self::Error> {
|
async fn create_user(&self, f: &AddUser<'_>) -> Result<(), Self::Error> {
|
||||||
let path = self.get_user_path(f.username, f.hostname, true).await?;
|
let path = self.get_user_path(f.username, f.hostname, true).await?;
|
||||||
|
|
Loading…
Reference in a new issue