mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
MemberProfile as public type & create user on auth.
This commit is contained in:
parent
665d9d2130
commit
d1fccf5ab6
@ -6,7 +6,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"demodesk/neko/internal/types"
|
||||
"demodesk/neko/internal/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -26,12 +25,9 @@ func (manager *SessionManagerCtx) Authenticate(r *http.Request) (types.Session,
|
||||
return nil, fmt.Errorf("invalid password")
|
||||
}
|
||||
|
||||
id, err := utils.NewUID(32)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return manager.New(id, isAdmin), nil
|
||||
return manager.Create(types.MemberProfile{
|
||||
IsAdmin: isAdmin,
|
||||
})
|
||||
}
|
||||
|
||||
func getToken(r *http.Request) string {
|
||||
|
@ -37,7 +37,7 @@ type SessionManagerCtx struct {
|
||||
emmiter events.EventEmmiter
|
||||
}
|
||||
|
||||
func (manager *SessionManagerCtx) Create(profile MemberProfile) (types.Session, error) {
|
||||
func (manager *SessionManagerCtx) Create(profile types.MemberProfile) (types.Session, error) {
|
||||
manager.membersMu.Lock()
|
||||
defer manager.membersMu.Unlock()
|
||||
|
||||
|
@ -8,21 +8,11 @@ import (
|
||||
"demodesk/neko/internal/types/message"
|
||||
)
|
||||
|
||||
type MemberProfile struct {
|
||||
//token string
|
||||
name string
|
||||
is_admin bool
|
||||
//enabled bool
|
||||
//can_control bool
|
||||
//can_watch bool
|
||||
//clipboard_access bool
|
||||
}
|
||||
|
||||
type SessionCtx struct {
|
||||
id string
|
||||
logger zerolog.Logger
|
||||
manager *SessionManagerCtx
|
||||
profile MemberProfile
|
||||
profile types.MemberProfile
|
||||
websocket_peer types.WebSocketPeer
|
||||
websocket_connected bool
|
||||
webrtc_peer types.WebRTCPeer
|
||||
@ -34,11 +24,11 @@ func (session *SessionCtx) ID() string {
|
||||
}
|
||||
|
||||
func (session *SessionCtx) Name() string {
|
||||
return session.profile.name
|
||||
return session.profile.Name
|
||||
}
|
||||
|
||||
func (session *SessionCtx) Admin() bool {
|
||||
return session.profile.is_admin
|
||||
return session.profile.IsAdmin
|
||||
}
|
||||
|
||||
func (session *SessionCtx) IsHost() bool {
|
||||
@ -50,7 +40,7 @@ func (session *SessionCtx) Connected() bool {
|
||||
}
|
||||
|
||||
func (session *SessionCtx) SetName(name string) {
|
||||
session.profile.name = name
|
||||
session.profile.Name = name
|
||||
}
|
||||
|
||||
func (session *SessionCtx) SetWebSocketPeer(websocket_peer types.WebSocketPeer) {
|
||||
|
@ -2,6 +2,16 @@ package types
|
||||
|
||||
import "net/http"
|
||||
|
||||
type MemberProfile struct {
|
||||
//Token string
|
||||
Name string
|
||||
IsAdmin bool
|
||||
//Enabled bool
|
||||
//CanControl bool
|
||||
//CanWatch bool
|
||||
//ClipboardAccess bool
|
||||
}
|
||||
|
||||
type Session interface {
|
||||
ID() string
|
||||
Name() string
|
||||
|
Loading…
Reference in New Issue
Block a user