From 2b1722c540237040ea04512fd0754ac5bcb05780 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Fri, 5 Apr 2019 17:07:40 +0200 Subject: [PATCH] (barely) working /manage endpoint --- database/src/types.rs | 2 +- dist/templates/email/manage-html.hbs | 27 +++ dist/templates/email/manage-txt.hbs | 10 ++ .../publish-html.hbs} | 0 .../publish-txt.hbs} | 0 dist/templates/index.html.hbs | 2 +- dist/templates/manage/manage.html.hbs | 21 +++ dist/templates/manage/manage_expired.html.hbs | 6 + dist/templates/manage/manage_key.html.hbs | 28 +++ .../manage/manage_link_sent.html.hbs | 8 + dist/templates/publish.html.hbs | 2 +- src/mail.rs | 18 +- src/tokens.rs | 13 +- src/web/manage.rs | 160 ++++++++++++++++++ src/web/mod.rs | 14 +- 15 files changed, 300 insertions(+), 11 deletions(-) create mode 100644 dist/templates/email/manage-html.hbs create mode 100644 dist/templates/email/manage-txt.hbs rename dist/templates/{publish-email-html.hbs => email/publish-html.hbs} (100%) rename dist/templates/{publish-email-txt.hbs => email/publish-txt.hbs} (100%) create mode 100644 dist/templates/manage/manage.html.hbs create mode 100644 dist/templates/manage/manage_expired.html.hbs create mode 100644 dist/templates/manage/manage_key.html.hbs create mode 100644 dist/templates/manage/manage_link_sent.html.hbs create mode 100644 src/web/manage.rs diff --git a/database/src/types.rs b/database/src/types.rs index 261fd23..f570c01 100644 --- a/database/src/types.rs +++ b/database/src/types.rs @@ -16,7 +16,7 @@ use {Error, Result}; /// - Lower-case the whole thing using the empty locale /// /// See https://autocrypt.org/level1.html#e-mail-address-canonicalization -#[derive(Serialize, Deserialize, Clone, Debug, Hash, PartialEq, Eq)] +#[derive(Serialize, Deserialize, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct Email(String); impl Email { diff --git a/dist/templates/email/manage-html.hbs b/dist/templates/email/manage-html.hbs new file mode 100644 index 0000000..7d79853 --- /dev/null +++ b/dist/templates/email/manage-html.hbs @@ -0,0 +1,27 @@ + + + + + Please confirm deletion of your key + + +

+ Someone, presumably you, requested that your key will no longer + be available when searching for you email addresses on + {{domain}}. +

+

+ If it was not you, please ignore this email. +

+

+ To de-list your key on {{domain}}, + follow this link: +

+

+ {{base_uri}}{{uri}} +

+

+ If you do not want to de-list your key, please ignore this + email. + + diff --git a/dist/templates/email/manage-txt.hbs b/dist/templates/email/manage-txt.hbs new file mode 100644 index 0000000..e9b1639 --- /dev/null +++ b/dist/templates/email/manage-txt.hbs @@ -0,0 +1,10 @@ +Someone, presumably you, requested that your key will no longer be +available when searching for you email addresses on {{domain}}. + +If it was not you, please ignore this email. + +To de-list your key on {{domain}}, follow this link: + + {{base_uri}}{{uri}} + +If you do not want to de-list your key, please ignore this email. diff --git a/dist/templates/publish-email-html.hbs b/dist/templates/email/publish-html.hbs similarity index 100% rename from dist/templates/publish-email-html.hbs rename to dist/templates/email/publish-html.hbs diff --git a/dist/templates/publish-email-txt.hbs b/dist/templates/email/publish-txt.hbs similarity index 100% rename from dist/templates/publish-email-txt.hbs rename to dist/templates/email/publish-txt.hbs diff --git a/dist/templates/index.html.hbs b/dist/templates/index.html.hbs index 16a35f9..27acdda 100644 --- a/dist/templates/index.html.hbs +++ b/dist/templates/index.html.hbs @@ -1,7 +1,7 @@ {{#> layout }} {{> search-form}}

-

You can also upload or delete your key.

+

You can also upload or delete your key.

diff --git a/dist/templates/manage/manage.html.hbs b/dist/templates/manage/manage.html.hbs new file mode 100644 index 0000000..2fdac31 --- /dev/null +++ b/dist/templates/manage/manage.html.hbs @@ -0,0 +1,21 @@ +{{#> layout }} +
+
+
+ + +
+
+
+ +
+

Please enter one of your email addesses.

+
+ +
+ « Back +
+{{/layout}} diff --git a/dist/templates/manage/manage_expired.html.hbs b/dist/templates/manage/manage_expired.html.hbs new file mode 100644 index 0000000..3fb0f8a --- /dev/null +++ b/dist/templates/manage/manage_expired.html.hbs @@ -0,0 +1,6 @@ +{{#> layout }} +
+

This management link is invalid or expired. +

You can click here to request a new one. +

+{{/layout}} diff --git a/dist/templates/manage/manage_key.html.hbs b/dist/templates/manage/manage_key.html.hbs new file mode 100644 index 0000000..1628245 --- /dev/null +++ b/dist/templates/manage/manage_key.html.hbs @@ -0,0 +1,28 @@ +{{#> layout }} +
+
+ {{#if uid_unpublished}} +
Unpublished address: {{uid_unpublished}}
+ {{/if}} +
+ {{#each uid_status}} +
+
+
+ + +   +
+
+

+ {{#if published}} + {{address}} + {{else}} + {{address}} + {{/if}} +

+ {{/each}} +
+
+
+{{/layout}} diff --git a/dist/templates/manage/manage_link_sent.html.hbs b/dist/templates/manage/manage_link_sent.html.hbs new file mode 100644 index 0000000..c304628 --- /dev/null +++ b/dist/templates/manage/manage_link_sent.html.hbs @@ -0,0 +1,8 @@ +{{#> layout }} +

+ We have sent an email with further instructions to {{address}}. +

+
+ « Back +
+{{/layout}} diff --git a/dist/templates/publish.html.hbs b/dist/templates/publish.html.hbs index e476ef4..3963168 100644 --- a/dist/templates/publish.html.hbs +++ b/dist/templates/publish.html.hbs @@ -19,7 +19,7 @@
-

You can delete an uploaded key here.

+

You can delete an uploaded key here.