mirror of
https://github.com/rustmailer/bichon.git
synced 2026-08-03 07:48:34 +02:00
fix(account): prevent IMAP password from being overwritten when editing account #7
This commit is contained in:
@@ -70,7 +70,6 @@ pub struct AuthConfig {
|
|||||||
///
|
///
|
||||||
/// Users should provide a plaintext password (1 to 256 characters).
|
/// Users should provide a plaintext password (1 to 256 characters).
|
||||||
/// The server will encrypt the password using AES-256-GCM and securely store it.
|
/// The server will encrypt the password using AES-256-GCM and securely store it.
|
||||||
/// The plaintext password is never stored, so users must remember it for authentication.
|
|
||||||
#[oai(validator(max_length = 256, min_length = 1))]
|
#[oai(validator(max_length = 256, min_length = 1))]
|
||||||
pub password: Option<String>,
|
pub password: Option<String>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
// You should have received a copy of the GNU Affero General Public License
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
use native_db::*;
|
use native_db::*;
|
||||||
use native_model::{native_model, Model};
|
use native_model::{native_model, Model};
|
||||||
|
|
||||||
@@ -323,12 +322,17 @@ impl AccountV1 {
|
|||||||
|
|
||||||
if matches!(old.account_type, AccountType::IMAP) {
|
if matches!(old.account_type, AccountType::IMAP) {
|
||||||
if let Some(imap) = &request.imap {
|
if let Some(imap) = &request.imap {
|
||||||
let mut new_imap = imap.clone();
|
if let Some(current_imap) = &mut new.imap {
|
||||||
if let Some(password) = &new_imap.auth.password {
|
current_imap.host = imap.host.clone();
|
||||||
let encrypted_password = encrypt!(password)?;
|
current_imap.port = imap.port.clone();
|
||||||
new_imap.auth.password = Some(encrypted_password);
|
current_imap.encryption = imap.encryption.clone();
|
||||||
|
current_imap.auth.auth_type = imap.auth.auth_type.clone();
|
||||||
|
if let Some(password) = &imap.auth.password {
|
||||||
|
let encrypted_password = encrypt!(password)?;
|
||||||
|
current_imap.auth.password = Some(encrypted_password);
|
||||||
|
}
|
||||||
|
current_imap.use_proxy = imap.use_proxy;
|
||||||
}
|
}
|
||||||
new.imap = Some(new_imap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(folder_names) = request.sync_folders {
|
if let Some(folder_names) = request.sync_folders {
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ pub async fn start_http_server() -> BichonResult<()> {
|
|||||||
.with(CatchPanic::new());
|
.with(CatchPanic::new());
|
||||||
|
|
||||||
let server = Server::new(listener)
|
let server = Server::new(listener)
|
||||||
.name("RustMailer API Service")
|
.name("Bichon Service")
|
||||||
.idle_timeout(Duration::from_secs(60))
|
.idle_timeout(Duration::from_secs(60))
|
||||||
.run_with_graceful_shutdown(
|
.run_with_graceful_shutdown(
|
||||||
route.catch_all_error(error_handler),
|
route.catch_all_error(error_handler),
|
||||||
@@ -130,7 +130,7 @@ pub async fn start_http_server() -> BichonResult<()> {
|
|||||||
Some(Duration::from_secs(5)),
|
Some(Duration::from_secs(5)),
|
||||||
);
|
);
|
||||||
println!(
|
println!(
|
||||||
"RustMailer API Service is now running on port {}.",
|
"Bichon Service is now running on port {}.",
|
||||||
SETTINGS.bichon_http_port
|
SETTINGS.bichon_http_port
|
||||||
);
|
);
|
||||||
server
|
server
|
||||||
|
|||||||
Reference in New Issue
Block a user