From a73dad2d4155699668ce14dc463913bb7892d3fc Mon Sep 17 00:00:00 2001 From: horus_arch Date: Sat, 21 Mar 2015 14:22:13 +0100 Subject: Skip dns validation if the MX record points to the correct server. Bugfix: Displays now flash message on success. --- handler.go | 2 +- server.go | 16 ++++++++++------ 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.") -- cgit v1.2.3