zitadel/internal/api/grpc/user/personal_access_token.go
Livio Amstutz 5d4351f47c
feat: merge main into v2 (#3193)
* feat(console): personal access tokens (#3185)

* token dialog, pat module

* pat components

* i18n, warn dialog, add token dialog

* cleanup dialog

* clipboard

* return creationDate of pat

* i18n

Co-authored-by: Livio Amstutz <livio.a@gmail.com>

* fix(cockroach): update to 21.2.5 (#3189)

Co-authored-by: Max Peintner <max@caos.ch>
Co-authored-by: Silvan <silvan.reusser@gmail.com>
2022-02-11 13:33:31 +01:00

26 lines
814 B
Go

package user
import (
"google.golang.org/protobuf/types/known/timestamppb"
"github.com/caos/zitadel/internal/api/grpc/object"
"github.com/caos/zitadel/internal/query"
"github.com/caos/zitadel/pkg/grpc/user"
)
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,
Details: object.ToViewDetailsPb(token.Sequence, token.CreationDate, token.ChangeDate, token.ResourceOwner),
ExpirationDate: timestamppb.New(token.Expiration),
Scopes: token.Scopes,
}
}