Skip to content

Commit

Permalink
resolve conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
olamilekan000 committed Aug 26, 2024
1 parent eb50a3c commit 95eeb29
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
9 changes: 9 additions & 0 deletions api/handlers/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,22 @@ import (
m "github.com/frain-dev/convoy/internal/pkg/middleware"
)

const (
ErrDisposableEmailNotAllowed = "disposable email not allowed."
)

func (h *Handler) RegisterUser(w http.ResponseWriter, r *http.Request) {
var newUser models.RegisterUser
if err := util.ReadJSON(r, &newUser); err != nil {
_ = render.Render(w, r, util.NewErrorResponse(err.Error(), http.StatusBadRequest))
return
}

if newUser.EmailIsDisposable() {
_ = render.Render(w, r, util.NewErrorResponse(ErrDisposableEmailNotAllowed, http.StatusBadRequest))
return
}

if err := newUser.Validate(); err != nil {
_ = render.Render(w, r, util.NewErrorResponse(err.Error(), http.StatusBadRequest))
return
Expand Down
13 changes: 13 additions & 0 deletions api/models/user.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package models

import (
emailverifier "github.com/AfterShip/email-verifier"

Check failure on line 4 in api/models/user.go

View workflow job for this annotation

GitHub Actions / test (1.21.x, macos-latest, 15, 6.2.6)

no required module provides package github.com/AfterShip/email-verifier; to add it:

"github.com/frain-dev/convoy/auth"
"github.com/frain-dev/convoy/datastore"
"github.com/frain-dev/convoy/util"
Expand All @@ -27,6 +29,17 @@ func (ru *RegisterUser) Validate() error {
return util.Validate(ru)
}

func (ru *RegisterUser) EmailIsDisposable() bool {
ret, err := emailverifier.NewVerifier().
EnableAutoUpdateDisposable().
Verify(ru.Email)
if err != nil {
return false
}

return ret.Disposable
}

type UpdateUser struct {
FirstName string `json:"first_name" valid:"required~please provide a first name"`
LastName string `json:"last_name" valid:"required~please provide a last name"`
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,4 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/dop251/goja_nodejs v0.0.0-20230821135201-94e508132562 => github.com/jirevwe/goja_nodejs v0.0.0-20240322142733-81d2fcfb82c1
replace github.com/dop251/goja_nodejs v0.0.0-20230821135201-94e508132562 => github.com/jirevwe/goja_nodejs v0.0.0-20240322142733-81d2fcfb82c1
2 changes: 1 addition & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2904,4 +2904,4 @@ sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
tags.cncf.io/container-device-interface v0.7.2 h1:MLqGnWfOr1wB7m08ieI4YJ3IoLKKozEnnNYBtacDPQU=
tags.cncf.io/container-device-interface v0.7.2/go.mod h1:Xb1PvXv2BhfNb3tla4r9JL129ck1Lxv9KuU6eVOfKto=
tags.cncf.io/container-device-interface v0.7.2/go.mod h1:Xb1PvXv2BhfNb3tla4r9JL129ck1Lxv9KuU6eVOfKto=

0 comments on commit 95eeb29

Please sign in to comment.