mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 22:52:22 +00:00
CLI: Allow editing principal password
This commit is contained in:
@@ -281,14 +281,17 @@ impl<AP: AuthenticationProvider> UserStore for OidcUserStore<AP> {
|
||||
|
||||
async fn insert_user(&self, id: &str) -> Result<(), Self::Error> {
|
||||
self.0
|
||||
.insert_principal(User {
|
||||
id: id.to_owned(),
|
||||
displayname: None,
|
||||
principal_type: Default::default(),
|
||||
password: None,
|
||||
app_tokens: vec![],
|
||||
memberships: vec![],
|
||||
})
|
||||
.insert_principal(
|
||||
User {
|
||||
id: id.to_owned(),
|
||||
displayname: None,
|
||||
principal_type: Default::default(),
|
||||
password: None,
|
||||
app_tokens: vec![],
|
||||
memberships: vec![],
|
||||
},
|
||||
false,
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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