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
+1
View File
@@ -16,4 +16,5 @@
@input!(ctx.1, password (password), "Password", form, errors, "minlenght=\"1\"")
<input type="submit" value="@i18n!(ctx.1, "Login")" />
</form>
<a href="@uri!(session::password_reset_request_form)">Forgot your password?</a>
})
+16
View File
@@ -0,0 +1,16 @@
@use template_utils::*;
@use templates::base;
@use routes::session::NewPasswordForm;
@use validator::ValidationErrors;
@(ctx: BaseContext, form: &NewPasswordForm, errors: ValidationErrors)
@:base(ctx, i18n!(ctx.1, "Reset your password"), {}, {}, {
<h1>@i18n!(ctx.1, "Reset your password")</h1>
<form method="POST">
@input!(ctx.1, password (password), "New password", form, errors.clone(), "minlenght=\"8\"")
@input!(ctx.1, password_confirmation (password), "Confirmation", form, errors.clone(), "minlenght=\"8\"")
<input type="submit" value="@i18n!(ctx.1, "Update password")" />
</form>
})
@@ -0,0 +1,15 @@
@use template_utils::*;
@use templates::base;
@use routes::session::ResetForm;
@use validator::ValidationErrors;
@(ctx: BaseContext, form: &ResetForm, errors: ValidationErrors)
@:base(ctx, i18n!(ctx.1, "Reset your password"), {}, {}, {
<h1>@i18n!(ctx.1, "Reset your password")</h1>
<form method="POST">
@input!(ctx.1, email (email), "E-mail", form, errors.clone(), "minlenght=\"1\"")
<input type="submit" value="@i18n!(ctx.1, "Send reset link")" />
</form>
})
@@ -0,0 +1,9 @@
@use template_utils::*;
@use templates::base;
@(ctx: BaseContext)
@:base(ctx, i18n!(ctx.1, "Password reset"), {}, {}, {
<h1>@i18n!(ctx.1, "Check your inbox!")</h1>
<p>@i18n!(ctx.1, "We sent a mail to the address you gave us, with a link to reset your password.")</p>
})