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
|
|
@ -4,7 +4,6 @@ import (
|
|||
"github.com/mikestefanello/pagoda/context"
|
||||
"github.com/mikestefanello/pagoda/controller"
|
||||
"github.com/mikestefanello/pagoda/ent"
|
||||
"github.com/mikestefanello/pagoda/ent/user"
|
||||
"github.com/mikestefanello/pagoda/msg"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
|
|
@ -63,10 +62,9 @@ func (c *ResetPassword) Post(ctx echo.Context) error {
|
|||
usr := ctx.Get(context.UserKey).(*ent.User)
|
||||
|
||||
// Update the user
|
||||
_, err = c.Container.ORM.User.
|
||||
_, err = usr.
|
||||
Update().
|
||||
SetPassword(hash).
|
||||
Where(user.ID(usr.ID)).
|
||||
Save(ctx.Request().Context())
|
||||
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -47,11 +47,10 @@ func (c *VerifyEmail) Get(ctx echo.Context) error {
|
|||
|
||||
// Verify the user, if needed
|
||||
if !usr.Verified {
|
||||
err = c.Container.ORM.User.
|
||||
usr, err = usr.
|
||||
Update().
|
||||
SetVerified(true).
|
||||
Where(user.ID(usr.ID)).
|
||||
Exec(ctx.Request().Context())
|
||||
Save(ctx.Request().Context())
|
||||
|
||||
if err != nil {
|
||||
return c.Fail(ctx, err, "failed to set user as verified")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue