fleet/server/service/metrics_change_email.go
John Murphy 9465434826 Allow user to change email with confirmation (#1102)
* Change email functionality

* Code review changes for @groob

* Name change per @groob

* Code review changes per @marpaia

Also added addition non-happy path tests to satisfy concerns by @groob
2017-01-27 21:35:58 +08:00

23 lines
531 B
Go

package service
import (
"fmt"
"time"
"golang.org/x/net/context"
)
func (mw metricsMiddleware) ChangeUserEmail(ctx context.Context, token string) (string, error) {
var (
err error
newEmail string
)
defer func(begin time.Time) {
lvs := []string{"method", "CommitEmailChange", "error", fmt.Sprint(err != nil)}
mw.requestCount.With(lvs...).Add(1)
mw.requestLatency.With(lvs...).Observe(time.Since(begin).Seconds())
}(time.Now())
newEmail, err = mw.Service.ChangeUserEmail(ctx, token)
return newEmail, err
}