From e92546887e24ab41d3b6efba940bf8720019be8e Mon Sep 17 00:00:00 2001 From: Kamil Slowikowski Date: Tue, 30 Jan 2018 11:49:26 -0500 Subject: [PATCH 1/3] fix errors --- app/controllers/app.go | 4 ++-- .../github.com/revel/modules/jobs/app/controllers/status.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/app.go b/app/controllers/app.go index 17f6165..a98effb 100644 --- a/app/controllers/app.go +++ b/app/controllers/app.go @@ -70,7 +70,7 @@ func (c Application) SwitchToDesktop() r.Result { // Add desktop mode cookie c.Session["desktopmode"] = "1" - referer, err := url.Parse(c.Request.Request.Header.Get("Referer")) + referer, err := url.Parse(c.Request.Header.Get("Referer")) if err != nil || referer.String() == "" { return c.Redirect(routes.Application.Index()) } @@ -82,7 +82,7 @@ func (c Application) SwitchToMobile() r.Result { // Remove desktop mode cookie delete(c.Session, "desktopmode") - referer, err := url.Parse(c.Request.Request.Header.Get("Referer")) + referer, err := url.Parse(c.Request.Header.Get("Referer")) if err != nil || referer.String() == "" { return c.Redirect(routes.Application.Index()) } diff --git a/vendor/github.com/revel/modules/jobs/app/controllers/status.go b/vendor/github.com/revel/modules/jobs/app/controllers/status.go index 5761329..c339ae2 100644 --- a/vendor/github.com/revel/modules/jobs/app/controllers/status.go +++ b/vendor/github.com/revel/modules/jobs/app/controllers/status.go @@ -15,8 +15,8 @@ type Jobs struct { func (c Jobs) Status() revel.Result { remoteAddress := c.Request.RemoteAddr if revel.Config.BoolDefault("jobs.acceptproxyaddress", false) { - if proxiedAddress, isProxied := c.Request.Header["X-Forwarded-For"]; isProxied { - remoteAddress = proxiedAddress[0] + if proxiedAddress := c.Request.Header.Get("X-Forwarded-For"); proxiedAddress != "" { + remoteAddress = proxiedAddress } } if !strings.HasPrefix(remoteAddress, "127.0.0.1") && From fac2416644daa1b3f044ba07e2acaf6f36b3181a Mon Sep 17 00:00:00 2001 From: Kamil Slowikowski Date: Tue, 30 Jan 2018 15:55:21 -0500 Subject: [PATCH 2/3] fix typos in send password reset email The path to the reset template is: app/views/email/reset.txt So, when the revel app is executed, the current working directory needs to be correct relative to the hardcoded path to the template. I'm not sure how to properly use relative paths for this. The mail server's address and port need to be separated by a colon ':' --- app/controllers/account.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/account.go b/app/controllers/account.go index 0b409b3..24af075 100644 --- a/app/controllers/account.go +++ b/app/controllers/account.go @@ -461,7 +461,7 @@ func (e Account) sendEmail(user *models.User, verifyType, subject string) error // send mail - t, tErr := template.ParseFiles("email/" + verifyType) + t, tErr := template.ParseFiles("views/email/" + verifyType + ".txt") if tErr != nil { return tErr } @@ -479,7 +479,7 @@ func (e Account) sendEmail(user *models.User, verifyType, subject string) error mailerAuth := smtp.PlainAuth("", mailerUsername, mailerPassword, mailerServer) - if sErr := smtp.SendMail(mailerServer + fmt.Sprintf("%v", mailerPort), mailerAuth, mailerFromAddr, []string{user.Email}, mailerMessage); sErr != nil { + if sErr := smtp.SendMail(mailerServer + fmt.Sprintf(":%v", mailerPort), mailerAuth, mailerFromAddr, []string{user.Email}, mailerMessage); sErr != nil { return sErr } From e3757db9e1758b01e706ae405246a68ff753aa58 Mon Sep 17 00:00:00 2001 From: Kamil Slowikowski Date: Tue, 30 Jan 2018 15:57:48 -0500 Subject: [PATCH 3/3] incremental changes for password reset --- app/controllers/account.go | 2 +- app/controllers/profile.go | 11 +++++++---- app/views/email/reset.html | 4 +--- app/views/email/reset.txt | 4 +--- app/views/header.html | 8 ++++---- app/views/profile/password.html | 4 ++-- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/controllers/account.go b/app/controllers/account.go index 24af075..22c1b10 100644 --- a/app/controllers/account.go +++ b/app/controllers/account.go @@ -320,7 +320,7 @@ func (c Account) PasswordReset(token string) r.Result { // Log user in, flash message and redirect to change password page c.DoLogin(existingProfile.User, false) c.Flash.Success("Please now enter a new password") - return c.Redirect(routes.Profile.Password(existingProfile.UserName)) + return c.Redirect(routes.Profile.Password()) } func (c Account) Logout() r.Result { diff --git a/app/controllers/profile.go b/app/controllers/profile.go index 1435274..62e1db5 100644 --- a/app/controllers/profile.go +++ b/app/controllers/profile.go @@ -191,14 +191,17 @@ func (c Profile) UpdateSettings(username string, profile *models.Profile, verify return c.Redirect(routes.Profile.Show(existingProfile.UserName)) } -func (c Profile) Password(username string) r.Result { +// FIXME This is broken. The password is not actually reset. +//func (c Profile) Password(username string) r.Result { +func (c Profile) Password() r.Result { + //profile := c.getProfileByUserName(username) + //user := profile.User profile := c.connected() - if profile == nil || profile.UserName != username { + if profile == nil { c.Flash.Error("You must log in to access your account") return c.Redirect(routes.Account.Logout()) } - - return c.Render() + return c.Render(profile) } func (c Profile) CommitPassword(user *models.User, password string) error { diff --git a/app/views/email/reset.html b/app/views/email/reset.html index 0d4dfed..2380770 100644 --- a/app/views/email/reset.html +++ b/app/views/email/reset.html @@ -1,5 +1,3 @@ -

Hello {{.user.Name}}

-

Please click the link below to reset your password:

-{{.Link}} \ No newline at end of file +{{.Link}} diff --git a/app/views/email/reset.txt b/app/views/email/reset.txt index 76209de..bdd752d 100644 --- a/app/views/email/reset.txt +++ b/app/views/email/reset.txt @@ -1,5 +1,3 @@ -Hello {{.user.Name}}, - Please click the link below to reset your password: -{{.Link}} \ No newline at end of file +{{.Link}} diff --git a/app/views/header.html b/app/views/header.html index 8fc9db3..ad37795 100644 --- a/app/views/header.html +++ b/app/views/header.html @@ -78,8 +78,8 @@
- Profile Photo - {{.user.Name}} + Profile Photo + {{.profile.Name}}
@@ -87,8 +87,8 @@ diff --git a/app/views/profile/password.html b/app/views/profile/password.html index 517a530..cf84847 100644 --- a/app/views/profile/password.html +++ b/app/views/profile/password.html @@ -10,7 +10,7 @@

Reset your password


-
+ {{with $field := field "password" .}}
@@ -38,7 +38,7 @@

Reset your password