2018-10-27 15:14:55 +02:00
|
|
|
package v1
|
|
|
|
|
|
|
|
import (
|
2018-10-31 13:42:38 +01:00
|
|
|
"code.vikunja.io/api/pkg/models"
|
|
|
|
"code.vikunja.io/api/pkg/routes/crud"
|
2018-10-27 15:14:55 +02:00
|
|
|
"github.com/labstack/echo"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
// UserConfirmEmail is the handler to confirm a user email
|
|
|
|
func UserConfirmEmail(c echo.Context) error {
|
|
|
|
// swagger:operation POST /user/confirm user confirmEmail
|
|
|
|
// ---
|
|
|
|
// summary: Confirms a users email address
|
|
|
|
// consumes:
|
|
|
|
// - application/json
|
|
|
|
// produces:
|
|
|
|
// - application/json
|
|
|
|
// parameters:
|
|
|
|
// - name: body
|
|
|
|
// in: body
|
|
|
|
// schema:
|
|
|
|
// "$ref": "#/definitions/EmailConfirm"
|
|
|
|
// responses:
|
|
|
|
// "200":
|
|
|
|
// "$ref": "#/responses/Message"
|
|
|
|
// "400":
|
|
|
|
// "$ref": "#/responses/Message"
|
|
|
|
// "404":
|
|
|
|
// "$ref": "#/responses/Message"
|
|
|
|
// "500":
|
|
|
|
// "$ref": "#/responses/Message"
|
|
|
|
|
|
|
|
// Check for Request Content
|
|
|
|
var emailConfirm models.EmailConfirm
|
|
|
|
if err := c.Bind(&emailConfirm); err != nil {
|
|
|
|
return echo.NewHTTPError(http.StatusBadRequest, "No token provided.")
|
|
|
|
}
|
|
|
|
|
|
|
|
err := models.UserEmailConfirm(&emailConfirm)
|
|
|
|
if err != nil {
|
|
|
|
return crud.HandleHTTPError(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.JSON(http.StatusOK, models.Message{"The email was confirmed successfully."})
|
|
|
|
}
|