From patchwork Thu Nov 2 05:54:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonatan Schlag X-Patchwork-Id: 1514 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.ipfire.org (Postfix) with ESMTP id 7DA2C60DB8 for ; Wed, 1 Nov 2017 19:54:24 +0100 (CET) Received: from mail01.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 3EA3811BB; Wed, 1 Nov 2017 19:54:24 +0100 (CET) Received: from bockland.local.familyschlag (unknown [10.172.1.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 82BB411BB; Wed, 1 Nov 2017 19:54:22 +0100 (CET) From: Jonatan Schlag To: pakfire@lists.ipfire.org Subject: [PATCH] Add mail feature to password reset Date: Wed, 1 Nov 2017 19:54:18 +0100 Message-Id: <20171101185418.10946-1-jonatan.schlag@ipfire.org> X-Mailer: git-send-email 2.11.0 X-BeenThere: pakfire@lists.ipfire.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Mailinglist for the Pakfire Build System." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: pakfire-bounces@lists.ipfire.org Sender: "Pakfire" We can now send an email with an reset code. Fixes: #10095 Signed-off-by: Jonatan Schlag --- Makefile.am | 3 ++- src/buildservice/users.py | 5 ++--- src/templates/messages/users/password-reset.markdown | 10 ++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 src/templates/messages/users/password-reset.markdown diff --git a/Makefile.am b/Makefile.am index cf6c610..918178e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -255,7 +255,8 @@ templates_messages_jobsdir = $(templates_messagesdir)/jobs dist_templates_messages_users_DATA = \ src/templates/messages/users/account-activation.markdown \ - src/templates/messages/users/email-activation.markdown + src/templates/messages/users/email-activation.markdown \ + src/templates/messages/users/password-reset.markdown templates_messages_usersdir = $(templates_messagesdir)/users diff --git a/src/buildservice/users.py b/src/buildservice/users.py index a886b82..01cf497 100644 --- a/src/buildservice/users.py +++ b/src/buildservice/users.py @@ -474,9 +474,8 @@ class User(base.DataObject): # Add a recovery code to the database and a timestamp when this code expires self.password_recovery_code = generate_random_string(64) - # XXX - # We should send an email with the activation code - + # Send an email with the activation code + self.send_template("messages/users/password-reset", user=self) @property def activated(self): diff --git a/src/templates/messages/users/password-reset.markdown b/src/templates/messages/users/password-reset.markdown new file mode 100644 index 0000000..b4f9fdf --- /dev/null +++ b/src/templates/messages/users/password-reset.markdown @@ -0,0 +1,10 @@ +Subject: {{ _("Password Reset") }} + +{{ _("You, or somebody else has requested a password reset for the Pakfire Build Service.") }} + +{{ _("To reset your password, please click on the link below:") }} + + {{ baseurl }}/password-reset?code={{ user.password_recovery_code }} + +Sincerely, +-The Pakfire Build Service