diff --git a/cmd/server/assets/users/show.html b/cmd/server/assets/users/show.html index a75dc52ae..bdba03133 100644 --- a/cmd/server/assets/users/show.html +++ b/cmd/server/assets/users/show.html @@ -43,6 +43,10 @@

{{$user.Name}}

{{$user.CanAdminRealm $currentRealm.ID}} +<<<<<<< HEAD + +======= +>>>>>>> upstream/main
{{ .csrfField }} diff --git a/pkg/controller/login/reset_password.go b/pkg/controller/login/reset_password.go index 0407c2f88..4aa096a2f 100644 --- a/pkg/controller/login/reset_password.go +++ b/pkg/controller/login/reset_password.go @@ -24,6 +24,8 @@ import ( "github.com/google/exposure-notifications-verification-server/internal/firebase" "github.com/google/exposure-notifications-verification-server/pkg/controller" "github.com/google/exposure-notifications-verification-server/pkg/controller/flash" + + "go.opencensus.io/stats" ) func (c *Controller) HandleShowResetPassword() http.Handler { @@ -58,7 +60,9 @@ func (c *Controller) HandleSubmitResetPassword() http.Handler { // Ensure that if we have a user, they have auth if user, err := c.db.FindUserByEmail(form.Email); err == nil { - user.CreateFirebaseUser(ctx, c.client) + if created, _ := user.CreateFirebaseUser(ctx, c.client); created { + stats.Record(ctx, c.db.Metrics.FirebaseRecreates.M(1)) + } } if err := c.firebaseInternal.SendPasswordResetEmail(ctx, strings.TrimSpace(form.Email)); err != nil { diff --git a/pkg/controller/user/user.go b/pkg/controller/user/controller.go similarity index 100% rename from pkg/controller/user/user.go rename to pkg/controller/user/controller.go diff --git a/pkg/controller/user/show.go b/pkg/controller/user/show.go index 0a7404867..13e4b1362 100644 --- a/pkg/controller/user/show.go +++ b/pkg/controller/user/show.go @@ -23,6 +23,8 @@ import ( "github.com/google/exposure-notifications-verification-server/pkg/controller" "github.com/google/exposure-notifications-verification-server/pkg/database" "github.com/gorilla/mux" + + "go.opencensus.io/stats" ) func (c *Controller) HandleShow() http.Handler { @@ -61,9 +63,13 @@ func (c *Controller) Show(w http.ResponseWriter, r *http.Request, resetPassword } if resetPassword { - if _, err := c.resetPassword(ctx, user); err == nil { + created, err := c.resetPassword(ctx, user) + if err == nil { flash.Alert("Password reset email sent.") } + if created { + stats.Record(ctx, c.db.Metrics.FirebaseRecreates.M(1)) + } } userStats, err := c.getStats(ctx, user, realm) diff --git a/pkg/database/database.go b/pkg/database/database.go index a76145ec4..a1f30835f 100644 --- a/pkg/database/database.go +++ b/pkg/database/database.go @@ -247,7 +247,7 @@ func IsNotFound(err error) bool { return errors.Is(err, gorm.ErrRecordNotFound) || gorm.IsRecordNotFoundError(err) } -// callbackIncremementMetric incremements the provided metric +// callbackIncrementMetric increments the provided metric func callbackIncrementMetric(ctx context.Context, m *stats.Int64Measure, table string) func(scope *gorm.Scope) { return func(scope *gorm.Scope) { if scope.TableName() != table {