Archived
Template
1
0

Various fixes (#5)

* Fixes #1

* Fixes #2

* Fixes #3

* Fixes #4
This commit is contained in:
Markus Tenghamn
2021-12-13 20:33:50 +01:00
committed by GitHub
parent c2493c238f
commit b5ba3d0387
234 changed files with 872 additions and 58627 deletions

View File

@ -11,12 +11,14 @@ import (
"net/http"
"net/url"
"path"
"time"
)
func (controller Controller) ForgotPassword(c *gin.Context) {
pd := PageData{
Title: "Forgot Password",
IsAuthenticated: isAuthenticated(c),
CacheParameter: controller.config.CacheParameter,
}
c.HTML(http.StatusOK, "forgotpassword.html", pd)
}
@ -25,6 +27,7 @@ func (controller Controller) ForgotPasswordPost(c *gin.Context) {
pd := PageData{
Title: "Forgot Password",
IsAuthenticated: isAuthenticated(c),
CacheParameter: controller.config.CacheParameter,
}
email := c.PostForm("email")
user := models.User{Email: email}
@ -57,6 +60,8 @@ func (controller Controller) forgotPasswordEmailHandler(userID uint, email strin
forgotPasswordToken.ModelID = int(userID)
forgotPasswordToken.ModelType = "User"
// The token will expire 10 minutes after it was created
forgotPasswordToken.ExpiresAt = time.Now().Add(time.Minute * 10)
res = controller.db.Save(&forgotPasswordToken)
if res.Error != nil || res.RowsAffected == 0 {