feat: auth handlers and session management

This commit is contained in:
2026-08-26 23:16:08 +08:00
parent 2852097b26
commit af6aba3d37
4 changed files with 229 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
package server
import (
"crypto/rand"
"encoding/hex"
"sync"
"time"
"yoresee_dropbox/internal/store"
)
type Server struct {
store *store.Store
accessToken string
sessions map[string]int64
shareSessions map[string]string
loginAttempts map[string]int
loginLockout map[string]time.Time
mu sync.Mutex
workspace string
}
func New(store *store.Store, accessToken string, workspace string) *Server {
return &Server{
store: store,
accessToken: accessToken,
sessions: make(map[string]int64),
shareSessions: make(map[string]string),
loginAttempts: make(map[string]int),
loginLockout: make(map[string]time.Time),
workspace: workspace,
}
}
func generateUUID() string {
b := make([]byte, 16)
rand.Read(b)
return hex.EncodeToString(b)
}