2021-05-20 11:33:35 +00:00
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
|
|
|
"google.golang.org/protobuf/types/known/timestamppb"
|
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/api/grpc/object"
|
|
|
|
"github.com/zitadel/zitadel/internal/user/model"
|
|
|
|
"github.com/zitadel/zitadel/pkg/grpc/user"
|
2021-05-20 11:33:35 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func RefreshTokensToPb(refreshTokens []*model.RefreshTokenView) []*user.RefreshToken {
|
|
|
|
tokens := make([]*user.RefreshToken, len(refreshTokens))
|
|
|
|
for i, token := range refreshTokens {
|
|
|
|
tokens[i] = RefreshTokenToPb(token)
|
|
|
|
}
|
|
|
|
return tokens
|
|
|
|
}
|
|
|
|
|
|
|
|
func RefreshTokenToPb(token *model.RefreshTokenView) *user.RefreshToken {
|
|
|
|
return &user.RefreshToken{
|
|
|
|
Id: token.ID,
|
|
|
|
Details: object.ToViewDetailsPb(token.Sequence, token.CreationDate, token.ChangeDate, token.ResourceOwner),
|
|
|
|
ClientId: token.ClientID,
|
|
|
|
AuthTime: timestamppb.New(token.AuthTime),
|
|
|
|
IdleExpiration: timestamppb.New(token.IdleExpiration),
|
|
|
|
Expiration: timestamppb.New(token.Expiration),
|
|
|
|
Scopes: token.Scopes,
|
|
|
|
Audience: token.Audience,
|
|
|
|
}
|
|
|
|
}
|