Password reset (#448)

* Password reset

* Various improvements and fixes for password reset

- Reorganize src/mail.rs to make it  cleaner
- add a build_mail function
- only make the requests invalid after 2 hours
- avoid infintely-growing list of requests by deleting them once completed, or after 24 hours
- avoid sending many requests for the same user
- validate the password reset form

* Avoid locking so many times

Fix durations

* Remove old requests even if the current one is not valid

* Remove unused feature

* Also remove the custom_derive and plugin features while we are at it

* Forgot a 0 è_é

* Avoid panicking while owning a request lock

* Use master branch of lettre so that we can build with the latest OpenSSL

* Fix the debug mailer
This commit is contained in:
Baptiste Gelez
2019-02-27 13:29:26 +01:00
committed by GitHub
parent e28371bbe4
commit a2b9d7ec44
21 changed files with 927 additions and 15 deletions
+17 -2
View File
@@ -1,4 +1,4 @@
#![feature(custom_derive, plugin, decl_macro, proc_macro_hygiene)]
#![feature(decl_macro, proc_macro_hygiene)]
extern crate activitypub;
extern crate askama_escape;
@@ -15,6 +15,8 @@ extern crate gettext_macros;
extern crate gettext_utils;
extern crate guid_create;
extern crate heck;
extern crate lettre;
extern crate lettre_email;
extern crate multipart;
extern crate num_cpus;
extern crate plume_api;
@@ -51,13 +53,14 @@ use plume_models::{
use scheduled_thread_pool::ScheduledThreadPool;
use std::env;
use std::process::exit;
use std::sync::Arc;
use std::sync::{Arc, Mutex};
use std::time::Duration;
init_i18n!("plume", ar, de, en, es, fr, gl, it, ja, nb, pl, pt, ru);
mod api;
mod inbox;
mod mail;
#[macro_use]
mod template_utils;
mod routes;
@@ -117,6 +120,12 @@ Then try to restart Plume.
.limit("forms", form_size * 1024)
.limit("json", activity_size * 1024));
let mail = mail::init();
if mail.is_none() && config.environment.is_prod() {
println!("Warning: the email server is not configured (or not completely).");
println!("Please refer to the documentation to see how to configure it.");
}
rocket::custom(config)
.mount("/", routes![
routes::blogs::details,
@@ -177,6 +186,10 @@ Then try to restart Plume.
routes::session::new,
routes::session::create,
routes::session::delete,
routes::session::password_reset_request_form,
routes::session::password_reset_request,
routes::session::password_reset_form,
routes::session::password_reset,
routes::static_files,
@@ -222,6 +235,8 @@ Then try to restart Plume.
routes::errors::unprocessable_entity,
routes::errors::server_error
])
.manage(Arc::new(Mutex::new(mail)))
.manage::<Arc<Mutex<Vec<routes::session::ResetRequest>>>>(Arc::new(Mutex::new(vec![])))
.manage(dbpool)
.manage(workpool)
.manage(searcher)