Files
access-manager-api/app/utils.go
T
alu de7ac282db implement pool group and user get routes,
improvements to http return codes,
add localdb backend handler
2026-04-29 21:15:20 +00:00

38 lines
713 B
Go

package app
import (
"fmt"
"net/http"
"github.com/gin-contrib/sessions"
"github.com/gin-gonic/gin"
localdb "user-manager-api/app/localdb"
pve "user-manager-api/app/pve"
)
type Realm struct {
Type string
Config any
}
type UserSession struct {
PVE *pve.ProxmoxClient
Realm struct {
Name string
Handler any
}
DB *localdb.DB
}
func GetUserSessionFromContext(c *gin.Context) (*UserSession, int, error) {
session := sessions.Default(c)
SessionUUID := session.Get("SessionUUID")
if SessionUUID == nil {
return nil, http.StatusUnauthorized, fmt.Errorf("No auth session found")
}
uuid := SessionUUID.(string)
usersession := UserSessions[uuid]
return usersession, http.StatusOK, nil
}