mhoppa commented on a change in pull request #3929: Rewrote
/user/reset_password to Go
URL: https://github.com/apache/trafficcontrol/pull/3929#discussion_r327207073
##########
File path: traffic_ops/traffic_ops_golang/login/login.go
##########
@@ -296,3 +353,117 @@ func VerifyUrlOnWhiteList(urlString string,
whiteListedUrls []string) (bool, err
}
return false, nil
}
+
+func setToken(addr rfc.EmailAddress, tx *sql.Tx) (string, error) {
+ token, err := uuid.NewRandom()
+ if err != nil {
+ return "", err
+ }
+ t := token.String()
+ if _,err = tx.Exec(setTokenQuery, t, addr.Address); err != nil {
+ return "", err
+ }
+ return t, nil
+}
+
+func createMsg(addr rfc.EmailAddress, t string, db *sqlx.DB, c
config.ConfigPortal) ([]byte, error) {
+ var instanceName string
+ row := db.QueryRow(instanceNameQuery)
+ if err := row.Scan(&instanceName); err != nil {
+ return nil, err
+ }
+ f := emailFormatter {
+ From: c.EmailFrom,
+ To: addr,
+ Token: t,
+ InstanceName: instanceName,
+ ResetURL: c.BaseURL,
+ }
+ f.ResetURL.Path += c.PasswdResetPath
+
+ var tmpl bytes.Buffer
+ if err := resetPasswordEmailTemplate.Execute(&tmpl, f); err != nil {
+ return nil, err
+ }
+ return tmpl.Bytes(), nil
+}
+
+func ResetPassword(db *sqlx.DB, cfg config.Config) http.HandlerFunc { return
func(w http.ResponseWriter, r *http.Request) {
+ var userErr, sysErr error
+ var errCode int
+ tx, err := db.Begin()
+ if err != nil {
+ sysErr = fmt.Errorf("Beginning transaction: %v", err)
Review comment:
duh :)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services