mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-15 12:27:59 +00:00
41d78ef523
* fix: return absolute url for avatar in user sessions * fix: refresh token unique constraint
28 lines
815 B
Go
28 lines
815 B
Go
package eventstore
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/zitadel/zitadel/internal/api/authz"
|
|
"github.com/zitadel/zitadel/internal/auth/repository/eventsourcing/view"
|
|
usr_model "github.com/zitadel/zitadel/internal/user/model"
|
|
"github.com/zitadel/zitadel/internal/user/repository/view/model"
|
|
)
|
|
|
|
type UserSessionRepo struct {
|
|
View *view.View
|
|
}
|
|
|
|
func (repo *UserSessionRepo) GetMyUserSessions(ctx context.Context) ([]*usr_model.UserSessionView, error) {
|
|
userSessions, err := repo.View.UserSessionsByAgentID(authz.GetCtxData(ctx).AgentID, authz.GetInstance(ctx).InstanceID())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return model.UserSessionsToModel(userSessions), nil
|
|
}
|
|
|
|
func (repo *UserSessionRepo) ActiveUserSessionCount() int64 {
|
|
userSessions, _ := repo.View.ActiveUserSessionsCount()
|
|
return int64(userSessions)
|
|
}
|