mirror of
https://github.com/acaloiaro/newsbox
synced 2026-07-21 10:12:26 +00:00
32 lines
722 B
Go
32 lines
722 B
Go
package actions
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"newsbox/internal"
|
|
"newsbox/models"
|
|
|
|
"github.com/gobuffalo/buffalo"
|
|
"github.com/gobuffalo/pop/v6"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
// UserEmailVerificatioHandler
|
|
func UserEmailVerificationHandler(c buffalo.Context) error {
|
|
tx := c.Value("tx").(*pop.Connection)
|
|
|
|
q := tx.Where("id = ?", c.Param("email_verification_id"))
|
|
uev := &models.UserEmailVerification{}
|
|
if err := q.EagerPreload().First(uev); err != nil {
|
|
return errors.WithStack(err)
|
|
}
|
|
|
|
tx.Destroy(uev)
|
|
|
|
c.Session().Set("current_user_id", uev.OwnerID)
|
|
c.Flash().Add("success", fmt.Sprintf("Welcome to %s!", internal.SiteName()))
|
|
|
|
// and redirect to the show page
|
|
return c.Redirect(http.StatusSeeOther, "/")
|
|
|
|
}
|