replaced fmt.Println with logger usage
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
@@ -18,6 +19,7 @@ import (
|
||||
|
||||
type (
|
||||
Auth struct {
|
||||
log *slog.Logger
|
||||
auth *authentication.Authenticator
|
||||
newLoginURL LoginURLProviderFunc
|
||||
accts *accounts.Store
|
||||
@@ -36,11 +38,13 @@ type (
|
||||
)
|
||||
|
||||
func NewAuth(
|
||||
logger *slog.Logger,
|
||||
auth *authentication.Authenticator,
|
||||
newLoginURL LoginURLProviderFunc,
|
||||
accts *accounts.Store,
|
||||
) *Auth {
|
||||
return &Auth{
|
||||
log: logger,
|
||||
auth: auth,
|
||||
newLoginURL: newLoginURL,
|
||||
accts: accts,
|
||||
@@ -133,7 +137,7 @@ func (a *Auth) AuthenticateAndAddIdentity(f response.HandlerFunc, assertions ...
|
||||
if refreshFloor := expiration.Add(-(idTokenLifetime / 4)); refreshFloor.Before(now) {
|
||||
accessToken, expiration, err = a.auth.RefreshAccessToken(ctx, accessToken)
|
||||
if err != nil {
|
||||
fmt.Println("failed to refresh access token:", err)
|
||||
a.log.Warn("failed to refresh access token", "error", err)
|
||||
return response.TemporaryRedirect("/").
|
||||
Body(io.NopCloser(bytes.NewBuffer([]byte(fmt.Sprintf("failed to refresh access token: %v", err))))).
|
||||
Cookie(cookies.Expired("access_token")), nil
|
||||
|
||||
Reference in New Issue
Block a user