mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: add more logs for oauth2
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"log/slog"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@@ -86,11 +87,10 @@ func (p *IdentityProvider) UserInfo(token string) (*idp.IdentityProviderUserInfo
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
var claims map[string]any
|
var claims map[string]any
|
||||||
err = json.Unmarshal(body, &claims)
|
if err := json.Unmarshal(body, &claims); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, errors.Wrap(err, "failed to unmarshal response body")
|
return nil, errors.Wrap(err, "failed to unmarshal response body")
|
||||||
}
|
}
|
||||||
|
slog.Info("user info claims", "claims", claims)
|
||||||
userInfo := &idp.IdentityProviderUserInfo{}
|
userInfo := &idp.IdentityProviderUserInfo{}
|
||||||
if v, ok := claims[p.config.FieldMapping.Identifier].(string); ok {
|
if v, ok := claims[p.config.FieldMapping.Identifier].(string); ok {
|
||||||
userInfo.Identifier = v
|
userInfo.Identifier = v
|
||||||
@@ -118,5 +118,6 @@ func (p *IdentityProvider) UserInfo(token string) (*idp.IdentityProviderUserInfo
|
|||||||
userInfo.AvatarURL = v
|
userInfo.AvatarURL = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
slog.Info("user info", "userInfo", userInfo)
|
||||||
return userInfo, nil
|
return userInfo, nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user