Skip to content

Commit

Permalink
add ory creation webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
d-g-town committed May 17, 2024
1 parent 911e0b5 commit e6cda9e
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions api/server/handlers/user/create_ory.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"errors"
"net/http"

"github.com/porter-dev/porter/internal/analytics"

"github.com/porter-dev/porter/internal/telemetry"

"gorm.io/gorm"

"github.com/porter-dev/porter/api/server/shared/apierrors"
"github.com/porter-dev/porter/internal/analytics"
"github.com/porter-dev/porter/internal/models"

"github.com/porter-dev/porter/api/server/handlers"
Expand Down Expand Up @@ -109,25 +110,25 @@ func (u *OryUserCreateHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
u.HandleAPIError(w, r, apierrors.NewErrInternal(err))
return
}

u.Config().AnalyticsClient.Identify(analytics.CreateSegmentIdentifyUser(user))

Check failure on line 114 in api/server/handlers/user/create_ory.go

View workflow job for this annotation

GitHub Actions / Go Linter

Error return value of `.Identify` is not checked (errcheck)

u.Config().AnalyticsClient.Track(analytics.UserCreateTrack(&analytics.UserCreateTrackOpts{

Check failure on line 116 in api/server/handlers/user/create_ory.go

View workflow job for this annotation

GitHub Actions / Go Linter

Error return value of `.Track` is not checked (errcheck)
UserScopedTrackOpts: analytics.GetUserScopedTrackOpts(user.ID),
Email: user.Email,
FirstName: user.FirstName,
LastName: user.LastName,
CompanyName: user.CompanyName,
ReferralMethod: request.Referral,
}))
} else {
existingUser.AuthProvider = models.AuthProvider_Ory
existingUser.ExternalId = request.UserId
existingUser.ExternalId = request.OryId
_, err = u.Repo().User().UpdateUser(existingUser)
if err != nil {
err = telemetry.Error(ctx, span, err, "error updating user")
u.HandleAPIError(w, r, apierrors.NewErrInternal(err))
return
}
}

u.Config().AnalyticsClient.Identify(analytics.CreateSegmentIdentifyUser(user))

u.Config().AnalyticsClient.Track(analytics.UserCreateTrack(&analytics.UserCreateTrackOpts{
UserScopedTrackOpts: analytics.GetUserScopedTrackOpts(user.ID),
Email: user.Email,
FirstName: user.FirstName,
LastName: user.LastName,
CompanyName: user.CompanyName,
ReferralMethod: request.Referral,
}))
}

0 comments on commit e6cda9e

Please sign in to comment.