extend example

This commit is contained in:
Pascal Fischer
2024-03-18 15:31:47 +01:00
parent 27c3a4c5d6
commit 0c6c5fdc70
71 changed files with 4481 additions and 216 deletions

View File

@@ -0,0 +1 @@
package users

View File

@@ -0,0 +1,27 @@
package users
import (
"github.com/netbirdio/netbird/management/refactor/resources/peers"
"github.com/netbirdio/netbird/management/refactor/resources/users/types"
)
type Manager interface {
GetUser(id string) (types.User, error)
}
type DefaultManager struct {
repository Repository
peerManager peers.Manager
}
func NewDefaultManager(repository Repository, peerManager peers.Manager) *DefaultManager {
return &DefaultManager{
repository: repository,
peerManager: peerManager,
}
}
func (d DefaultManager) GetUser(id string) (types.User, error) {
// TODO implement me
panic("implement me")
}

View File

@@ -0,0 +1 @@
package personal_access_tokens

View File

@@ -0,0 +1 @@
package personal_access_tokens

View File

@@ -0,0 +1 @@
package personal_access_tokens

View File

@@ -0,0 +1,4 @@
package users
type Repository interface {
}

View File

@@ -0,0 +1,35 @@
package types
import "time"
// UserRole is the role of a User
type UserRole string
type User interface {
IsBlocked() bool
}
// User represents a user of the system
type DefaultUser struct {
Id string `gorm:"primaryKey"`
// AccountID is a reference to Account that this object belongs
AccountID string `json:"-" gorm:"index"`
Role UserRole
IsServiceUser bool
// NonDeletable indicates whether the service user can be deleted
NonDeletable bool
// ServiceUserName is only set if IsServiceUser is true
ServiceUserName string
// AutoGroups is a list of Group IDs to auto-assign to peers registered by this user
AutoGroups []string `gorm:"serializer:json"`
// Blocked indicates whether the user is blocked. Blocked users can't use the system.
Blocked bool
// LastLogin is the last time the user logged in to IdP
LastLogin time.Time
// Issued of the user
Issued string `gorm:"default:api"`
}
func (u *DefaultUser) IsBlocked() bool {
return u.Blocked
}