refactor: prefer anonymous clients

This commit is contained in:
James Houlahan
2020-04-08 12:51:16 +02:00
parent b01be382fc
commit 5bf4d9c6f5
2 changed files with 4 additions and 9 deletions

View File

@ -340,13 +340,8 @@ func getAPIUser(client pmapi.Client, auth *pmapi.Auth, mbPassword string) (user
return
}
if _, err = client.Unlock(hashedPassword); err != nil {
log.WithError(err).Error("Could not decrypt keyring")
return
}
if user, err = client.UpdateUser(); err != nil {
log.WithError(err).Error("Could not update API user")
log.WithError(err).Error("Could not load API user")
return
}
@ -439,7 +434,7 @@ func (b *Bridge) DeleteUser(userID string, clearStore bool) error {
// ReportBug reports a new bug from the user.
func (b *Bridge) ReportBug(osType, osVersion, description, accountName, address, emailClient string) error {
c := b.clientManager.GetClient("bug_reporter")
c := b.clientManager.GetAnonymousClient()
defer c.Logout()
title := "[Bridge] Bug"
@ -463,7 +458,7 @@ func (b *Bridge) ReportBug(osType, osVersion, description, accountName, address,
// SendMetric sends a metric. We don't want to return any errors, only log them.
func (b *Bridge) SendMetric(m metrics.Metric) {
c := b.clientManager.GetClient("metric_reporter")
c := b.clientManager.GetAnonymousClient()
defer c.Logout()
cat, act, lab := m.Get()

View File

@ -65,7 +65,7 @@ func GetLogEntry(packageName string) *logrus.Entry {
func HandlePanic(cfg *Config, output string) {
if !cfg.IsDevMode() {
// TODO: Is it okay to just create a throwaway client like this?
c := pmapi.NewClientManager(cfg.GetAPIConfig()).GetClient("no-user-id")
c := pmapi.NewClientManager(cfg.GetAPIConfig()).GetAnonymousClient()
defer c.Logout()
if err := c.ReportSentryCrash(fmt.Errorf(output)); err != nil {