Skip to content

Commit abcf738

Browse files
Fix setup of ses keys (#1526)
1 parent 9b57f3b commit abcf738

File tree

3 files changed

+90
-6
lines changed

3 files changed

+90
-6
lines changed

actions/ses.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package actions
33
import (
44
"fmt"
55
"net/http"
6+
"net/url"
67
"os"
78

89
"github.com/aws/aws-sdk-go/aws"
@@ -118,8 +119,11 @@ func createAWSResources(
118119
snsClient events.EventsClient,
119120
uuid string,
120121
) error {
121-
hookURL := fmt.Sprintf("%s/api/hooks/%s", os.Getenv("APP_URL"), uuid)
122-
122+
hookURLStr := fmt.Sprintf("%s/api/hooks/%s", os.Getenv("APP_URL"), uuid)
123+
hookURL, err := url.Parse(hookURLStr)
124+
if err != nil {
125+
return fmt.Errorf("ses keys: unable to parse hook URL: %w", err)
126+
}
123127
snsRes, err := snsClient.CreateTopic(&sns.CreateTopicInput{
124128
Name: aws.String(events.SNSTopicName),
125129
})
@@ -130,8 +134,8 @@ func createAWSResources(
130134
topicArn := *snsRes.TopicArn
131135

132136
_, err = snsClient.Subscribe(&sns.SubscribeInput{
133-
Protocol: aws.String("https"),
134-
Endpoint: aws.String(hookURL),
137+
Protocol: aws.String(hookURL.Scheme),
138+
Endpoint: aws.String(hookURLStr),
135139
TopicArn: aws.String(topicArn),
136140
})
137141
if err != nil {

storage/db.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
log "github.com/sirupsen/logrus"
1717
"golang.org/x/crypto/bcrypt"
1818

19-
"github.com/mailbadger/app/mode"
2019
_ "github.com/mailbadger/app/statik"
2120

2221
"github.com/mailbadger/app/entities"
@@ -70,7 +69,7 @@ func openDbConn(driver, config string) *gorm.DB {
7069
log.WithError(err).Fatalln("migrations failed")
7170
}
7271

73-
db.LogMode(mode.IsDebug())
72+
// db.LogMode(mode.IsDebug())
7473

7574
return db
7675
}
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;">
3+
<head>
4+
<meta name="viewport" content="width=device-width" />
5+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6+
<title>Actionable emails e.g. reset password</title>
7+
8+
9+
<style type="text/css">
10+
img {
11+
max-width: 100%;
12+
}
13+
body {
14+
-webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; line-height: 1.6em;
15+
}
16+
body {
17+
background-color: #f6f6f6;
18+
}
19+
@media only screen and (max-width: 640px) {
20+
body {
21+
padding: 0 !important;
22+
}
23+
h1 {
24+
font-weight: 800 !important; margin: 20px 0 5px !important;
25+
}
26+
h2 {
27+
font-weight: 800 !important; margin: 20px 0 5px !important;
28+
}
29+
h3 {
30+
font-weight: 800 !important; margin: 20px 0 5px !important;
31+
}
32+
h4 {
33+
font-weight: 800 !important; margin: 20px 0 5px !important;
34+
}
35+
h1 {
36+
font-size: 22px !important;
37+
}
38+
h2 {
39+
font-size: 18px !important;
40+
}
41+
h3 {
42+
font-size: 16px !important;
43+
}
44+
.container {
45+
padding: 0 !important; width: 100% !important;
46+
}
47+
.content {
48+
padding: 0 !important;
49+
}
50+
.content-wrap {
51+
padding: 10px !important;
52+
}
53+
.invoice {
54+
width: 100% !important;
55+
}
56+
}
57+
</style>
58+
</head>
59+
60+
<body itemscope itemtype="http://schema.org/EmailMessage" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: none; width: 100% !important; height: 100%; line-height: 1.6em; background-color: #f6f6f6; margin: 0;" bgcolor="#f6f6f6">
61+
62+
<table class="body-wrap" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; width: 100%; background-color: #f6f6f6; margin: 0;" bgcolor="#f6f6f6"><tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"><td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;" valign="top"></td>
63+
<td class="container" width="600" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; display: block !important; max-width: 600px !important; clear: both !important; margin: 0 auto;" valign="top">
64+
<div class="content" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; max-width: 600px; display: block; margin: 0 auto; padding: 20px;">
65+
<table class="main" width="100%" cellpadding="0" cellspacing="0" itemprop="action" itemscope itemtype="http://schema.org/ConfirmAction" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; border-radius: 3px; background-color: #fff; margin: 0; border: 1px solid #e9e9e9;" bgcolor="#fff"><tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"><td class="content-wrap" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 20px;" valign="top">
66+
<meta itemprop="name" content="Confirm Email" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;" /><table width="100%" cellpadding="0" cellspacing="0" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"><tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"><td class="content-block" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" valign="top">
67+
Click the following link to add a new password
68+
</td>
69+
</tr><tr style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; margin: 0;"><td class="content-block" itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0; padding: 0 0 20px;" valign="top">
70+
<a href="{{.url}}" class="btn-primary" itemprop="url" style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; color: #FFF; text-decoration: none; line-height: 2em; font-weight: bold; text-align: center; cursor: pointer; display: inline-block; border-radius: 5px; text-transform: capitalize; background-color: #348eda; margin: 0; border-color: #348eda; border-style: solid; border-width: 10px 20px;">Confirm email address</a>
71+
</td>
72+
</td>
73+
</tr></table></td>
74+
</tr>
75+
</table>
76+
</div>
77+
</div>
78+
</td>
79+
<td style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; vertical-align: top; margin: 0;" valign="top"></td>
80+
</tr></table></body>
81+
</html>

0 commit comments

Comments
 (0)