Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions api/handler/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func (u user) GetDeviceStatus(c echo.Context) error {
// @Produce json
// @Security ApiKeyAuth
// @Param id path string true "User ID"
// @Param body body model.PreValidateEmail true "Pre Validate Email"
// @Param email query string true "Pre Validated Email"
// @Success 200 {object} ResultMessage
// @Failure 400 {object} error
// @Failure 401 {object} error
Expand All @@ -335,24 +335,17 @@ func (u user) GetDeviceStatus(c echo.Context) error {
func (u user) PreValidateEmail(c echo.Context) error {
ctx := c.Request().Context()
userId := c.Param("id")
email := c.QueryParam("email")
platformId, ok := c.Get("platformId").(string)
if !ok {
return httperror.Internal500(c, "missing or invalid platformId")
}

// Get email from body
var body model.PreValidateEmail
err := c.Bind(&body)
if err != nil {
libcommon.LogStringError(c, err, "user: pre validate email bind")
return httperror.BadRequest400(c)
}

if !validator.ValidEmail(body.Email) {
if !validator.ValidEmail(email) {
return httperror.BadRequest400(c, "Invalid email")
}

err = u.verification.PreValidateEmail(ctx, platformId, userId, body.Email)
err := u.verification.PreValidateEmail(ctx, platformId, userId, email)
if err != nil {
// ?
return DefaultErrorHandler(c, err, "platformInternal: PreValidateEmail")
Expand Down
4 changes: 0 additions & 4 deletions pkg/model/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,3 @@ type DeviceUpdates struct {
type RefreshTokenPayload struct {
WalletAddress string `json:"walletAddress" validate:"required,eth_addr"`
}

type PreValidateEmail struct {
Email string `json:"email" validate:"required,email"`
}