summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhorus_arch2015-03-21 14:22:13 +0100
committerhorus_arch2015-03-21 14:22:13 +0100
commita73dad2d4155699668ce14dc463913bb7892d3fc (patch)
tree0d4e2c54184141d33d82ca4c60a2a3f0f8608c6b
parentfc0c1682b1753c5d02650d6a18671b67959065af (diff)
downloadfreemail-a73dad2d4155699668ce14dc463913bb7892d3fc.tar.gz
Skip dns validation if the MX record points to the correct server. Bugfix: Displays now flash message on success.
-rw-r--r--handler.go2
-rw-r--r--server.go16
2 files changed, 11 insertions, 7 deletions
diff --git a/handler.go b/handler.go
index dd761e4..8fab6e8 100644
--- a/handler.go
+++ b/handler.go
@@ -101,7 +101,7 @@ func CreateNewEntryHandler(w http.ResponseWriter, r *http.Request) {
return
}
- session.AddFlash("Success! You can login now with your new mail account.")
+ session.AddFlash("Success! You can login now with your new mail account.", "success")
session.Save(r, w)
http.Redirect(w, r, "/", 302)
}
diff --git a/server.go b/server.go
index 746ac92..6447dc9 100644
--- a/server.go
+++ b/server.go
@@ -8,7 +8,8 @@ import (
)
func CreateNewEntry(email, password string) error {
- serverIP := os.Getenv("FREEMAIL_SMTP_MAILER_MX")
+ server := os.Getenv("FREEMAIL_SMTP_MAILER_MX")
+
if !ValidateEmail(email) {
return errors.New("This doesn't look like a mail adress.")
}
@@ -22,11 +23,11 @@ func CreateNewEntry(email, password string) error {
vD := VirtualDomain{}
vD.Name = GetDomain(vU.Email)
- if !vD.ValidateDomainMX(serverIP) {
- return errors.New("The MX record doesn't point to this server.")
- }
- if !vD.ValidateDomain(serverIP) {
- return errors.New("This doesn't look like a good domain. Host not found.")
+ // Checks for correct DNS
+ if !vD.ValidateDomainMX(server) {
+ if !vD.ValidateDomain(server) {
+ return errors.New("Neither the MX record nor the domain itself point to this server. Please fix your DNS.")
+ }
}
if !vD.DomainExists() {
@@ -36,6 +37,9 @@ func CreateNewEntry(email, password string) error {
}
vU.DomainId = vD.GetPrimaryKey()
+ if vU.DomainId == 0 {
+ return errors.New("There was an error.")
+ }
if !vU.CreateEmail() {
return errors.New("There was an error.")