Skip to content

Commit

Permalink
only allow activated accounts to login
Browse files Browse the repository at this point in the history
  • Loading branch information
bueti committed Nov 13, 2023
1 parent fe0ef0b commit 0a9abce
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/api/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ func (app *application) handleFormLogin(c echo.Context) error {
data := app.newTemplateData(c)
return c.Render(http.StatusUnauthorized, "login.tmpl.html", data)
}
if !user.Activated {
app.sessionManager.Put(c.Request().Context(), "flash_error", "Your user account has not been activated. Please check your mailbox for the activation link.")
data := app.newTemplateData(c)
return c.Render(http.StatusUnauthorized, "login.tmpl.html", data)
}
userID := user.ID.String()
app.sessionManager.Put(c.Request().Context(), "authenticated", true)
app.sessionManager.Put(c.Request().Context(), "userID", userID)
Expand Down

0 comments on commit 0a9abce

Please sign in to comment.