neko/pkg/types/member.go

49 lines
1.8 KiB
Go
Raw Normal View History

2021-03-13 23:42:16 +01:00
package types
2021-08-29 17:09:13 +02:00
import "errors"
var (
ErrMemberAlreadyExists = errors.New("member already exists")
ErrMemberDoesNotExist = errors.New("member does not exist")
ErrMemberInvalidPassword = errors.New("invalid password")
)
2021-03-14 12:57:19 +01:00
type MemberProfile struct {
2022-05-08 00:15:36 +02:00
Name string `json:"name"`
// permissions
IsAdmin bool `json:"is_admin" mapstructure:"is_admin"`
CanLogin bool `json:"can_login" mapstructure:"can_login"`
CanConnect bool `json:"can_connect" mapstructure:"can_connect"`
CanWatch bool `json:"can_watch" mapstructure:"can_watch"`
CanHost bool `json:"can_host" mapstructure:"can_host"`
CanShareMedia bool `json:"can_share_media" mapstructure:"can_share_media"`
CanAccessClipboard bool `json:"can_access_clipboard" mapstructure:"can_access_clipboard"`
SendsInactiveCursor bool `json:"sends_inactive_cursor" mapstructure:"sends_inactive_cursor"`
CanSeeInactiveCursors bool `json:"can_see_inactive_cursors" mapstructure:"can_see_inactive_cursors"`
2022-05-08 00:15:36 +02:00
// plugin scope
Plugins map[string]any `json:"plugins"`
2021-03-14 12:57:19 +01:00
}
2021-03-14 16:58:18 +01:00
type MemberProvider interface {
2021-03-13 23:42:16 +01:00
Connect() error
Disconnect() error
2023-01-12 23:32:42 +01:00
Authenticate(username string, password string) (id string, profile MemberProfile, err error)
2021-03-14 12:57:19 +01:00
2023-01-12 23:32:42 +01:00
Insert(username string, password string, profile MemberProfile) (id string, err error)
Select(id string) (profile MemberProfile, err error)
SelectAll(limit int, offset int) (profiles map[string]MemberProfile, err error)
2021-03-14 14:44:03 +01:00
UpdateProfile(id string, profile MemberProfile) error
2021-03-14 16:23:14 +01:00
UpdatePassword(id string, password string) error
2021-03-13 23:42:16 +01:00
Delete(id string) error
}
2021-03-14 16:58:18 +01:00
type MemberManager interface {
MemberProvider
2021-03-14 19:59:34 +01:00
Login(username string, password string) (Session, string, error)
Logout(id string) error
2021-03-14 16:58:18 +01:00
}