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"
|
"strings"
|
||||||
|
|
||||||
"demodesk/neko/internal/types"
|
"demodesk/neko/internal/types"
|
||||||
"demodesk/neko/internal/utils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -26,12 +25,9 @@ func (manager *SessionManagerCtx) Authenticate(r *http.Request) (types.Session,
|
|||||||
return nil, fmt.Errorf("invalid password")
|
return nil, fmt.Errorf("invalid password")
|
||||||
}
|
}
|
||||||
|
|
||||||
id, err := utils.NewUID(32)
|
return manager.Create(types.MemberProfile{
|
||||||
if err != nil {
|
IsAdmin: isAdmin,
|
||||||
return nil, err
|
})
|
||||||
}
|
|
||||||
|
|
||||||
return manager.New(id, isAdmin), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getToken(r *http.Request) string {
|
func getToken(r *http.Request) string {
|
||||||
|
@ -37,7 +37,7 @@ type SessionManagerCtx struct {
|
|||||||
emmiter events.EventEmmiter
|
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()
|
manager.membersMu.Lock()
|
||||||
defer manager.membersMu.Unlock()
|
defer manager.membersMu.Unlock()
|
||||||
|
|
||||||
|
@ -8,21 +8,11 @@ import (
|
|||||||
"demodesk/neko/internal/types/message"
|
"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 {
|
type SessionCtx struct {
|
||||||
id string
|
id string
|
||||||
logger zerolog.Logger
|
logger zerolog.Logger
|
||||||
manager *SessionManagerCtx
|
manager *SessionManagerCtx
|
||||||
profile MemberProfile
|
profile types.MemberProfile
|
||||||
websocket_peer types.WebSocketPeer
|
websocket_peer types.WebSocketPeer
|
||||||
websocket_connected bool
|
websocket_connected bool
|
||||||
webrtc_peer types.WebRTCPeer
|
webrtc_peer types.WebRTCPeer
|
||||||
@ -34,11 +24,11 @@ func (session *SessionCtx) ID() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (session *SessionCtx) Name() string {
|
func (session *SessionCtx) Name() string {
|
||||||
return session.profile.name
|
return session.profile.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *SessionCtx) Admin() bool {
|
func (session *SessionCtx) Admin() bool {
|
||||||
return session.profile.is_admin
|
return session.profile.IsAdmin
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *SessionCtx) IsHost() bool {
|
func (session *SessionCtx) IsHost() bool {
|
||||||
@ -50,7 +40,7 @@ func (session *SessionCtx) Connected() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (session *SessionCtx) SetName(name string) {
|
func (session *SessionCtx) SetName(name string) {
|
||||||
session.profile.name = name
|
session.profile.Name = name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (session *SessionCtx) SetWebSocketPeer(websocket_peer types.WebSocketPeer) {
|
func (session *SessionCtx) SetWebSocketPeer(websocket_peer types.WebSocketPeer) {
|
||||||
|
@ -2,6 +2,16 @@ package types
|
|||||||
|
|
||||||
import "net/http"
|
import "net/http"
|
||||||
|
|
||||||
|
type MemberProfile struct {
|
||||||
|
//Token string
|
||||||
|
Name string
|
||||||
|
IsAdmin bool
|
||||||
|
//Enabled bool
|
||||||
|
//CanControl bool
|
||||||
|
//CanWatch bool
|
||||||
|
//ClipboardAccess bool
|
||||||
|
}
|
||||||
|
|
||||||
type Session interface {
|
type Session interface {
|
||||||
ID() string
|
ID() string
|
||||||
Name() string
|
Name() string
|
||||||
|
Loading…
Reference in New Issue
Block a user