Merge pull request #6 from rithujohn191/api-resp-fic
server/api: return empty list of refresh tokens if user does not have any
This commit is contained in:
commit
65318da86e
1 changed files with 9 additions and 2 deletions
|
@ -215,13 +215,20 @@ func (d dexAPI) ListRefresh(ctx context.Context, req *api.ListRefreshReq) (*api.
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var refreshTokenRefs []*api.RefreshTokenRef
|
||||||
offlineSessions, err := d.s.GetOfflineSessions(id.UserId, id.ConnId)
|
offlineSessions, err := d.s.GetOfflineSessions(id.UserId, id.ConnId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
d.logger.Errorf("api: failed to list refresh tokens: %v", err)
|
if err == storage.ErrNotFound {
|
||||||
|
// This means that this user-client pair does not have a refresh token yet.
|
||||||
|
// An empty list should be returned instead of an error.
|
||||||
|
return &api.ListRefreshResp{
|
||||||
|
RefreshTokens: refreshTokenRefs,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
d.logger.Errorf("api: failed to list refresh tokens %t here : %v", err == storage.ErrNotFound, err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var refreshTokenRefs []*api.RefreshTokenRef
|
|
||||||
for _, session := range offlineSessions.Refresh {
|
for _, session := range offlineSessions.Refresh {
|
||||||
r := api.RefreshTokenRef{
|
r := api.RefreshTokenRef{
|
||||||
Id: session.ID,
|
Id: session.ID,
|
||||||
|
|
Reference in a new issue