mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 17:12:22 +00:00
CLI: Allow editing principal password
This commit is contained in:
@@ -9,7 +9,7 @@ pub trait AuthenticationProvider: 'static {
|
||||
async fn get_principals(&self) -> Result<Vec<User>, crate::Error>;
|
||||
async fn get_principal(&self, id: &str) -> Result<Option<User>, crate::Error>;
|
||||
async fn remove_principal(&self, id: &str) -> Result<(), crate::Error>;
|
||||
async fn insert_principal(&self, user: User) -> Result<(), crate::Error>;
|
||||
async fn insert_principal(&self, user: User, overwrite: bool) -> Result<(), crate::Error>;
|
||||
async fn validate_password(&self, user_id: &str, password: &str)
|
||||
-> Result<Option<User>, Error>;
|
||||
async fn validate_app_token(&self, user_id: &str, token: &str) -> Result<Option<User>, Error>;
|
||||
|
||||
@@ -69,9 +69,9 @@ impl AuthenticationProvider for TomlPrincipalStore {
|
||||
Ok(self.principals.read().await.get(id).cloned())
|
||||
}
|
||||
|
||||
async fn insert_principal(&self, user: User) -> Result<(), crate::Error> {
|
||||
async fn insert_principal(&self, user: User, overwrite: bool) -> Result<(), crate::Error> {
|
||||
let mut principals = self.principals.write().await;
|
||||
if principals.contains_key(&user.id) {
|
||||
if !overwrite && principals.contains_key(&user.id) {
|
||||
return Err(Error::AlreadyExists);
|
||||
}
|
||||
principals.insert(user.id.clone(), user);
|
||||
|
||||
Reference in New Issue
Block a user