From d1b7583ed48904512375255592c58175396502c7 Mon Sep 17 00:00:00 2001 From: kifen Date: Tue, 13 Aug 2019 12:24:10 +0100 Subject: [PATCH 1/5] adding feature to disable email validation when on testnet network --- controllers/main.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/controllers/main.go b/controllers/main.go index c83b4f94..022ed96a 100644 --- a/controllers/main.go +++ b/controllers/main.go @@ -1646,9 +1646,11 @@ func (controller *MainController) LoginPost(c web.C, r *http.Request) (string, i log.Infof("Login POST from %v, email %v", remoteIP, user.Email) - if user.EmailVerified == 0 { - session.AddFlash("You must validate your email address", "loginError") - return controller.Login(c, r) + if verified := user.EmailVerified; controller.getNetworkName() != "testnet" { + if verified == 0 { + session.AddFlash("You must validate your email address", "loginError") + return controller.Login(c, r) + } } session.Values["UserId"] = user.Id @@ -1760,12 +1762,14 @@ func (controller *MainController) RegisterPost(c web.C, r *http.Request) (string return controller.Register(c, r) } - err = controller.emailSender.Registration(email, controller.baseURL, remoteIP, token.String()) - if err != nil { - session.AddFlash("Unable to send verification email", "registrationError") - log.Errorf("error sending verification email %v", err) - } else { - session.AddFlash("A verification email has been sent to "+email, "registrationSuccess") + if controller.getNetworkName() != "testnet" { + err = controller.emailSender.Registration(email, controller.baseURL, remoteIP, token.String()) + if err != nil { + session.AddFlash("Unable to send verification email", "registrationError") + log.Errorf("error sending verification email %v", err) + } else { + session.AddFlash("A verification email has been sent to "+email, "registrationSuccess") + } } return controller.Register(c, r) From a65217d8b34ad70b1612dc49009e2928ccb413a0 Mon Sep 17 00:00:00 2001 From: kifen Date: Tue, 13 Aug 2019 12:24:10 +0100 Subject: [PATCH 2/5] disabling email verification and validation when on testnet network --- controllers/main.go | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/controllers/main.go b/controllers/main.go index c83b4f94..022ed96a 100644 --- a/controllers/main.go +++ b/controllers/main.go @@ -1646,9 +1646,11 @@ func (controller *MainController) LoginPost(c web.C, r *http.Request) (string, i log.Infof("Login POST from %v, email %v", remoteIP, user.Email) - if user.EmailVerified == 0 { - session.AddFlash("You must validate your email address", "loginError") - return controller.Login(c, r) + if verified := user.EmailVerified; controller.getNetworkName() != "testnet" { + if verified == 0 { + session.AddFlash("You must validate your email address", "loginError") + return controller.Login(c, r) + } } session.Values["UserId"] = user.Id @@ -1760,12 +1762,14 @@ func (controller *MainController) RegisterPost(c web.C, r *http.Request) (string return controller.Register(c, r) } - err = controller.emailSender.Registration(email, controller.baseURL, remoteIP, token.String()) - if err != nil { - session.AddFlash("Unable to send verification email", "registrationError") - log.Errorf("error sending verification email %v", err) - } else { - session.AddFlash("A verification email has been sent to "+email, "registrationSuccess") + if controller.getNetworkName() != "testnet" { + err = controller.emailSender.Registration(email, controller.baseURL, remoteIP, token.String()) + if err != nil { + session.AddFlash("Unable to send verification email", "registrationError") + log.Errorf("error sending verification email %v", err) + } else { + session.AddFlash("A verification email has been sent to "+email, "registrationSuccess") + } } return controller.Register(c, r) From 431263c2b1f327f713c7faf868383e37b89750d3 Mon Sep 17 00:00:00 2001 From: kifen Date: Tue, 13 Aug 2019 12:57:17 +0100 Subject: [PATCH 3/5] merging if statement --- controllers/main.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/controllers/main.go b/controllers/main.go index 022ed96a..517ed051 100644 --- a/controllers/main.go +++ b/controllers/main.go @@ -1646,11 +1646,9 @@ func (controller *MainController) LoginPost(c web.C, r *http.Request) (string, i log.Infof("Login POST from %v, email %v", remoteIP, user.Email) - if verified := user.EmailVerified; controller.getNetworkName() != "testnet" { - if verified == 0 { - session.AddFlash("You must validate your email address", "loginError") - return controller.Login(c, r) - } + if (user.EmailVerified == 0 && controller.getNetworkName() != "testnet") { + session.AddFlash("You must validate your email address", "loginError") + return controller.Login(c, r) } session.Values["UserId"] = user.Id From 4c19855d0dff36e2a86ec5575a85839b539f58d6 Mon Sep 17 00:00:00 2001 From: kifen Date: Wed, 21 Aug 2019 11:04:18 +0100 Subject: [PATCH 4/5] enabling email verification over testnet --- controllers/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/main.go b/controllers/main.go index 517ed051..163a9e85 100644 --- a/controllers/main.go +++ b/controllers/main.go @@ -1646,7 +1646,7 @@ func (controller *MainController) LoginPost(c web.C, r *http.Request) (string, i log.Infof("Login POST from %v, email %v", remoteIP, user.Email) - if (user.EmailVerified == 0 && controller.getNetworkName() != "testnet") { + if (user.EmailVerified == 0) { session.AddFlash("You must validate your email address", "loginError") return controller.Login(c, r) } From c613588b41c711b805217fee7e78a979d6f44cd3 Mon Sep 17 00:00:00 2001 From: kifen Date: Wed, 21 Aug 2019 11:05:52 +0100 Subject: [PATCH 5/5] removing brackets from if condition --- controllers/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/controllers/main.go b/controllers/main.go index 163a9e85..39da4818 100644 --- a/controllers/main.go +++ b/controllers/main.go @@ -1646,7 +1646,7 @@ func (controller *MainController) LoginPost(c web.C, r *http.Request) (string, i log.Infof("Login POST from %v, email %v", remoteIP, user.Email) - if (user.EmailVerified == 0) { + if user.EmailVerified == 0 { session.AddFlash("You must validate your email address", "loginError") return controller.Login(c, r) }