Skip to content

Commit

Permalink
Additional check of email in firebase for the GetValidUserForPhoneNum…
Browse files Browse the repository at this point in the history
…berMigration (#97)
  • Loading branch information
ice-myles authored Jan 15, 2024
1 parent cd4960f commit 95cc49e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
11 changes: 10 additions & 1 deletion cmd/eskimo-hut/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ func parseProcessFaceRecognitionResultRequest(req *server.Request[ProcessFaceRec
// @Failure 500 {object} server.ErrorResponse
// @Failure 504 {object} server.ErrorResponse "if request times out"
// @Router /auth/getValidUserForPhoneNumberMigration [POST].
func (s *service) GetValidUserForPhoneNumberMigration( //nolint:funlen // .
func (s *service) GetValidUserForPhoneNumberMigration( //nolint:funlen,revive // .
ctx context.Context,
req *server.Request[GetValidUserForPhoneNumberMigrationArg, User],
) (successResp *server.Response[User], errorResp *server.Response[server.ErrorResponse]) {
Expand Down Expand Up @@ -508,6 +508,15 @@ func (s *service) GetValidUserForPhoneNumberMigration( //nolint:funlen // .
} else if emailUsedBySomebodyElse {
return nil, server.Conflict(users.ErrDuplicate, emailUsedBySomebodyElseEmail)
}
if req.Data.Email != "" {
if uid, gErr := server.Auth(ctx).GetUserUIDByEmail(ctx, req.Data.Email); gErr != nil || uid != "" {
if gErr != nil {
return nil, server.Unexpected(err)
}

return nil, server.Conflict(users.ErrDuplicate, emailUsedBySomebodyElseEmail)
}
}

minimalUsr := new(User)
minimalUsr.User = new(users.User)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/google/uuid v1.5.0
github.com/hashicorp/go-multierror v1.1.1
github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb
github.com/ice-blockchain/wintr v1.128.0
github.com/ice-blockchain/wintr v1.129.0
github.com/imroc/req/v3 v3.42.3
github.com/ip2location/ip2location-go/v9 v9.7.0
github.com/jackc/pgx/v5 v5.5.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb h1:8TnFP3mc7O+tc44kv2e0/TpZKnEVUaKH+UstwfBwRkk=
github.com/ice-blockchain/go-tarantool-client v0.0.0-20230327200757-4fc71fa3f7bb/go.mod h1:ZsQU7i3mxhgBBu43Oev7WPFbIjP4TniN/b1UPNGbrq8=
github.com/ice-blockchain/wintr v1.128.0 h1:ABiIfL4AfpJ4kPGScnPzQW2SJV8JSoc4IQWhng96UYE=
github.com/ice-blockchain/wintr v1.128.0/go.mod h1:Wq/uG3vDL/Na9lhpOo9NI7y3gLNZn2u/oa6+t85GT9c=
github.com/ice-blockchain/wintr v1.129.0 h1:MizJObFfcA+iOZe2Q7l2yZD5BMMqyABKWoMn12osuGo=
github.com/ice-blockchain/wintr v1.129.0/go.mod h1:Wq/uG3vDL/Na9lhpOo9NI7y3gLNZn2u/oa6+t85GT9c=
github.com/imroc/req/v3 v3.42.3 h1:ryPG2AiwouutAopwPxKpWKyxgvO8fB3hts4JXlh3PaE=
github.com/imroc/req/v3 v3.42.3/go.mod h1:Axz9Y/a2b++w5/Jht3IhQsdBzrG1ftJd1OJhu21bB2Q=
github.com/ip2location/ip2location-go/v9 v9.7.0 h1:ipwl67HOWcrw+6GOChkEXcreRQR37NabqBd2ayYa4Q0=
Expand Down

0 comments on commit 95cc49e

Please sign in to comment.