mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-14 02:17:34 +00:00
chore: move the go code into a subfolder
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package view
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/query"
|
||||
"github.com/zitadel/zitadel/internal/telemetry/tracing"
|
||||
usr_view "github.com/zitadel/zitadel/internal/user/repository/view"
|
||||
"github.com/zitadel/zitadel/internal/user/repository/view/model"
|
||||
)
|
||||
|
||||
const (
|
||||
tokenTable = "auth.tokens"
|
||||
)
|
||||
|
||||
func (v *View) TokenByIDs(tokenID, userID, instanceID string) (*model.TokenView, error) {
|
||||
return usr_view.TokenByIDs(v.Db, tokenTable, tokenID, userID, instanceID)
|
||||
}
|
||||
|
||||
func (v *View) TokensByUserID(userID, instanceID string) ([]*model.TokenView, error) {
|
||||
return usr_view.TokensByUserID(v.Db, tokenTable, userID, instanceID)
|
||||
}
|
||||
|
||||
func (v *View) GetLatestTokenSequence(ctx context.Context, instanceID string) (_ *query.CurrentState, err error) {
|
||||
ctx, span := tracing.NewSpan(ctx)
|
||||
defer func() { span.EndWithError(err) }()
|
||||
|
||||
q := &query.CurrentStateSearchQueries{
|
||||
Queries: make([]query.SearchQuery, 2),
|
||||
}
|
||||
q.Queries[0], err = query.NewCurrentStatesInstanceIDSearchQuery(instanceID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
q.Queries[1], err = query.NewCurrentStatesProjectionSearchQuery(tokenTable)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
states, err := v.query.SearchCurrentStates(ctx, q)
|
||||
if err != nil || states.SearchResponse.Count == 0 {
|
||||
return nil, err
|
||||
}
|
||||
return states.CurrentStates[0], nil
|
||||
}
|
Reference in New Issue
Block a user