修复刷新令牌
This commit is contained in:
parent
23892f19c7
commit
5c738aed9c
@ -26,7 +26,7 @@ type Token struct {
|
||||
AccessToken string `json:"accessToken"`
|
||||
AvailableProfiles []TokenProfile `json:"availableProfiles,omitempty"`
|
||||
ClientToken string `json:"clientToken"`
|
||||
SelectedProfile TokenProfile `json:"selectedProfile,omitempty"`
|
||||
SelectedProfile TokenProfile `json:"selectedProfile"`
|
||||
User TokenUser `json:"user,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ func newYggdrasil(r *httprouter.Router, handelY yggdrasil.Yggdrasil) error {
|
||||
r.POST("/api/authserver/validate", warpHJSON(handelY.Validate()))
|
||||
r.POST("/api/authserver/signout", warpHJSON(handelY.Signout()))
|
||||
r.POST("/api/authserver/invalidate", handelY.Invalidate())
|
||||
// TODO /authserver/refresh
|
||||
r.POST("/api/authserver/refresh", handelY.Refresh())
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/xmdhs/authlib-skin/db/ent"
|
||||
"github.com/xmdhs/authlib-skin/db/ent/user"
|
||||
"github.com/xmdhs/authlib-skin/db/ent/userprofile"
|
||||
"github.com/xmdhs/authlib-skin/db/ent/usertoken"
|
||||
"github.com/xmdhs/authlib-skin/model/yggdrasil"
|
||||
sutils "github.com/xmdhs/authlib-skin/service/utils"
|
||||
@ -148,11 +149,22 @@ func (y *Yggdrasil) Refresh(ctx context.Context, token yggdrasil.RefreshToken) (
|
||||
if err != nil {
|
||||
return yggdrasil.Token{}, fmt.Errorf("Authenticate: %w", err)
|
||||
}
|
||||
|
||||
up, err := y.client.UserProfile.Query().Where(userprofile.UUIDEQ(t.Subject)).First(ctx)
|
||||
if err != nil {
|
||||
return yggdrasil.Token{}, fmt.Errorf("Authenticate: %w", err)
|
||||
}
|
||||
|
||||
return yggdrasil.Token{
|
||||
AccessToken: jwts,
|
||||
ClientToken: t.CID,
|
||||
SelectedProfile: yggdrasil.TokenProfile{
|
||||
ID: up.UUID,
|
||||
Name: up.Name,
|
||||
},
|
||||
User: yggdrasil.TokenUser{
|
||||
ID: t.Subject,
|
||||
ID: t.Subject,
|
||||
Properties: []any{},
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user