2022-02-08 08:37:28 +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/query"
|
|
|
|
"github.com/zitadel/zitadel/pkg/grpc/user"
|
2022-02-08 08:37:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func PersonalAccessTokensToPb(tokens []*query.PersonalAccessToken) []*user.PersonalAccessToken {
|
|
|
|
t := make([]*user.PersonalAccessToken, len(tokens))
|
|
|
|
for i, token := range tokens {
|
|
|
|
t[i] = PersonalAccessTokenToPb(token)
|
|
|
|
}
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
func PersonalAccessTokenToPb(token *query.PersonalAccessToken) *user.PersonalAccessToken {
|
|
|
|
return &user.PersonalAccessToken{
|
|
|
|
Id: token.ID,
|
2022-02-11 12:33:31 +00:00
|
|
|
Details: object.ToViewDetailsPb(token.Sequence, token.CreationDate, token.ChangeDate, token.ResourceOwner),
|
2022-02-08 08:37:28 +00:00
|
|
|
ExpirationDate: timestamppb.New(token.Expiration),
|
|
|
|
Scopes: token.Scopes,
|
|
|
|
}
|
|
|
|
}
|