Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reset password #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/controllers/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand All @@ -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())
}
Expand Down
11 changes: 7 additions & 4 deletions app/controllers/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 1 addition & 3 deletions app/views/email/reset.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<h1>Hello {{.user.Name}}</h1>

<p>Please click the link below to reset your password:</p>

<a href="{{.user.Link}}">{{.Link}}</a>
<a href="{{.Link}}">{{.Link}}</a>
4 changes: 1 addition & 3 deletions app/views/email/reset.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
Hello {{.user.Name}},

Please click the link below to reset your password:

{{.Link}}
{{.Link}}
8 changes: 4 additions & 4 deletions app/views/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@
<div class="media">
<div class="media-body">
<div class="media-heading">
<img class="img-rounded" src="{{.user.PhotoUrl}}" alt="Profile Photo" width="20" height="20" style="border: 1px solid #666; margin-top: -4px; margin-right: 4px;">
{{.user.Name}}
<img class="img-rounded" src="{{.profile.PhotoUrl}}" alt="Profile Photo" width="20" height="20" style="border: 1px solid #666; margin-top: -4px; margin-right: 4px;">
{{.profile.Name}}
<span class="caret"></span>
</div>
</div>
</div>
</a>

<ul class="dropdown-menu">
<li><a href="{{url "Profile.Show" .user.UserName}}">View Profile</a></li>
<li><a href="{{url "Profile.Settings" .user.UserName}}">Edit Profile</a></li>
<li><a href="{{url "Profile.Show" .profile.UserName}}">View Profile</a></li>
<li><a href="{{url "Profile.Settings" .profile.UserName}}">Edit Profile</a></li>
<li class="divider"></li>
<li><a href="{{url "Account.Logout"}}">Logout</a></li>
</ul>
Expand Down
4 changes: 2 additions & 2 deletions app/views/profile/password.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h2>Reset your password</h2>

<hr>

<form action="{{url "Profile.UpdatePassword" .user.UserId}}" method="POST" class="form-horizontal" role="form">
<form action="{{url "Profile.UpdatePassword" .profile.UserId}}" method="POST" class="form-horizontal" role="form">
{{with $field := field "password" .}}
<div class="form-group{{if $field.Error}} has-error{{end}}">
<label for="{{$field.Name}}" class="col-sm-2 control-label">Password</label>
Expand Down Expand Up @@ -38,7 +38,7 @@ <h2>Reset your password</h2>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" class="btn btn-primary" value="Save New Password">
<a href="{{url "Profile.Show" .user.UserName}}" type="submit" class="btn btn-default">Cancel</a>
<a href="{{url "Profile.Show" .profile.UserName}}" type="submit" class="btn btn-default">Cancel</a>
</div>
</div>
</form>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.