Use entity update method rather than query. Fixed password reset form action.
This commit is contained in:
parent
acd38c8205
commit
d412e06dad
4 changed files with 7 additions and 8 deletions
|
|
@ -118,7 +118,7 @@ Go server-side rendered HTML combined with the projects below enable you to crea
|
||||||
|
|
||||||
### Screenshots
|
### Screenshots
|
||||||
|
|
||||||
#### Inline validation
|
#### Inline form validation
|
||||||
|
|
||||||
<img src="https://user-images.githubusercontent.com/552328/147838632-570a3116-1e74-428f-8bfc-523ed309ef06.png" alt="Inline validation"/>
|
<img src="https://user-images.githubusercontent.com/552328/147838632-570a3116-1e74-428f-8bfc-523ed309ef06.png" alt="Inline validation"/>
|
||||||
|
|
||||||
|
|
@ -761,6 +761,7 @@ Many examples of its usage are available in the included examples:
|
||||||
- All navigation links use [boost](https://htmx.org/docs/#boosting) which dynamically replaces the page content with an AJAX request, providing a SPA-like experience.
|
- All navigation links use [boost](https://htmx.org/docs/#boosting) which dynamically replaces the page content with an AJAX request, providing a SPA-like experience.
|
||||||
- All forms use either [boost](https://htmx.org/docs/#boosting) or [hx-post](https://htmx.org/docs/#triggers) to submit via AJAX.
|
- All forms use either [boost](https://htmx.org/docs/#boosting) or [hx-post](https://htmx.org/docs/#triggers) to submit via AJAX.
|
||||||
- The mock search autocomplete modal uses [hx-get](https://htmx.org/docs/#targets) to fetch search results from the server via AJAX and update the UI.
|
- The mock search autocomplete modal uses [hx-get](https://htmx.org/docs/#targets) to fetch search results from the server via AJAX and update the UI.
|
||||||
|
- The mock posts on the homepage/dashboard use [hx-get](https://htmx.org/docs/#targets) to fetch and page posts vi AJAX.
|
||||||
|
|
||||||
All of this can be easily accomplished without writing any JavaScript at all.
|
All of this can be easily accomplished without writing any JavaScript at all.
|
||||||
|
|
||||||
|
|
@ -947,6 +948,7 @@ Thank you to all of the following amazing projects for making this possible.
|
||||||
- [bulma](https://github.com/jgthms/bulma)
|
- [bulma](https://github.com/jgthms/bulma)
|
||||||
- [docker](https://www.docker.com/)
|
- [docker](https://www.docker.com/)
|
||||||
- [echo](https://github.com/labstack/echo)
|
- [echo](https://github.com/labstack/echo)
|
||||||
|
- [echo-contrib](https://github.com/labstack/echo-contrib)
|
||||||
- [ent](https://github.com/ent/ent)
|
- [ent](https://github.com/ent/ent)
|
||||||
- [envdecode](https://github.com/joeshaw/envdecode)
|
- [envdecode](https://github.com/joeshaw/envdecode)
|
||||||
- [go](https://go.dev/)
|
- [go](https://go.dev/)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"github.com/mikestefanello/pagoda/context"
|
"github.com/mikestefanello/pagoda/context"
|
||||||
"github.com/mikestefanello/pagoda/controller"
|
"github.com/mikestefanello/pagoda/controller"
|
||||||
"github.com/mikestefanello/pagoda/ent"
|
"github.com/mikestefanello/pagoda/ent"
|
||||||
"github.com/mikestefanello/pagoda/ent/user"
|
|
||||||
"github.com/mikestefanello/pagoda/msg"
|
"github.com/mikestefanello/pagoda/msg"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
|
|
@ -63,10 +62,9 @@ func (c *ResetPassword) Post(ctx echo.Context) error {
|
||||||
usr := ctx.Get(context.UserKey).(*ent.User)
|
usr := ctx.Get(context.UserKey).(*ent.User)
|
||||||
|
|
||||||
// Update the user
|
// Update the user
|
||||||
_, err = c.Container.ORM.User.
|
_, err = usr.
|
||||||
Update().
|
Update().
|
||||||
SetPassword(hash).
|
SetPassword(hash).
|
||||||
Where(user.ID(usr.ID)).
|
|
||||||
Save(ctx.Request().Context())
|
Save(ctx.Request().Context())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -47,11 +47,10 @@ func (c *VerifyEmail) Get(ctx echo.Context) error {
|
||||||
|
|
||||||
// Verify the user, if needed
|
// Verify the user, if needed
|
||||||
if !usr.Verified {
|
if !usr.Verified {
|
||||||
err = c.Container.ORM.User.
|
usr, err = usr.
|
||||||
Update().
|
Update().
|
||||||
SetVerified(true).
|
SetVerified(true).
|
||||||
Where(user.ID(usr.ID)).
|
Save(ctx.Request().Context())
|
||||||
Exec(ctx.Request().Context())
|
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Fail(ctx, err, "failed to set user as verified")
|
return c.Fail(ctx, err, "failed to set user as verified")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
{{define "content"}}
|
{{define "content"}}
|
||||||
<form method="post" hx-boost="true" action="{{call .ToURL "forgot_password.post"}}">
|
<form method="post" hx-boost="true" action="{{.Path}}">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label for="password" class="label">Password</label>
|
<label for="password" class="label">Password</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue