Skip to content

Commit

Permalink
Don't store reset password's token in URL path
Browse files Browse the repository at this point in the history
  • Loading branch information
jinzhu committed Oct 11, 2017
1 parent a100ada commit d0a475c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions providers/password/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ func (provider Provider) ServeHTTP(context *auth.Context) {
}
case "edit":
// render edit password page
if len(paths) == 3 {
if token := context.Request.URL.Query().Get("token"); token != "" {
context.Auth.Config.Render.Funcs(template.FuncMap{
"reset_password_token": func() string { return paths[2] },
"reset_password_token": func() string { return token },
}).Execute("auth/password/edit", context, context.Request, context.Writer)
return
}
Expand Down
5 changes: 4 additions & 1 deletion providers/password/reset_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ var DefaultResetPasswordMailer = func(email string, context *auth.Context, claim
},
"reset_password_url": func() string {
resetPasswordURL := utils.GetAbsURL(context.Request)
resetPasswordURL.Path = path.Join(context.Auth.AuthURL("password/edit"), context.SessionStorer.SignedToken(claims))
resetPasswordURL.Path = path.Join(context.Auth.AuthURL("password/edit"))
qry := resetPasswordURL.Query()
qry.Set("token", context.SessionStorer.SignedToken(claims))
resetPasswordURL.RawQuery = qry.Encode()
return resetPasswordURL.String()
},
}),
Expand Down

0 comments on commit d0a475c

Please sign in to comment.