initial: ZeroTier-like P2P mesh VPN server with multi-tenant Web UI
This commit is contained in:
23
internal/handler/context.go
Normal file
23
internal/handler/context.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package handler
|
||||
|
||||
import "github.com/gin-gonic/gin"
|
||||
|
||||
func userID(c *gin.Context) uint {
|
||||
id, exists := c.Get("user_id")
|
||||
if !exists {
|
||||
return 0
|
||||
}
|
||||
uid, ok := id.(uint)
|
||||
if !ok {
|
||||
return 0
|
||||
}
|
||||
return uid
|
||||
}
|
||||
|
||||
func isAdmin(c *gin.Context) bool {
|
||||
role, exists := c.Get("role")
|
||||
if !exists {
|
||||
return false
|
||||
}
|
||||
return role.(string) == "admin"
|
||||
}
|
||||
Reference in New Issue
Block a user