Handle context cancellations and avoid logged errors.

This commit is contained in:
mikestefanello 2022-01-09 00:23:26 -05:00
parent a6e99058f4
commit 10c0a23c0a
8 changed files with 83 additions and 35 deletions

View file

@ -24,6 +24,9 @@ func LoadAuthenticatedUser(authClient *services.AuthClient) echo.MiddlewareFunc
c.Set(context.AuthenticatedUserKey, u)
c.Logger().Infof("auth user loaded in to context: %d", u.ID)
default:
if context.IsCanceledError(err) {
return nil
}
c.Logger().Errorf("error querying for authenticated user: %v", err)
}
@ -55,6 +58,9 @@ func LoadValidPasswordToken(authClient *services.AuthClient) echo.MiddlewareFunc
msg.Warning(c, "The link is either invalid or has expired. Please request a new one.")
return c.Redirect(http.StatusFound, c.Echo().Reverse("forgot_password"))
default:
if context.IsCanceledError(err) {
return nil
}
c.Logger().Error(err)
return echo.NewHTTPError(http.StatusInternalServerError)
}