wtf auth??
This commit is contained in:
parent
607d7e121c
commit
a3a1654030
14 changed files with 337 additions and 1 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
|
||||
"git.sapphic.engineer/roleypoly/v4/authmiddleware"
|
||||
"git.sapphic.engineer/roleypoly/v4/discord"
|
||||
"git.sapphic.engineer/roleypoly/v4/types"
|
||||
)
|
||||
|
@ -15,8 +16,14 @@ type TestingController struct {
|
|||
|
||||
func (t *TestingController) Routes(r fiber.Router) {
|
||||
r.Get("/picker/:version?", t.Picker)
|
||||
r.Get("/index", t.Index)
|
||||
r.Get("/m/:server/:user", t.GetMember)
|
||||
r.Get("/g/:server", t.GetGuild)
|
||||
r.Get("/auth", t.AuthState, authmiddleware.New(t.Guilds.Client(), []string{}, []string{}))
|
||||
}
|
||||
|
||||
func (t *TestingController) Index(c fiber.Ctx) error {
|
||||
return c.Render("index", fiber.Map{})
|
||||
}
|
||||
|
||||
func (t *TestingController) Picker(c fiber.Ctx) error {
|
||||
|
@ -54,3 +61,27 @@ func (t *TestingController) GetGuild(c fiber.Ctx) error {
|
|||
|
||||
return c.JSON(g.DiscordGuild)
|
||||
}
|
||||
|
||||
func (t *TestingController) AuthState(c fiber.Ctx) error {
|
||||
s := authmiddleware.SessionFrom(c)
|
||||
|
||||
permList := []string{}
|
||||
|
||||
if s.Permissions >= authmiddleware.PermAnonymous {
|
||||
permList = append(permList, "anonymous")
|
||||
}
|
||||
|
||||
if s.Permissions >= authmiddleware.PermUser {
|
||||
permList = append(permList, "user")
|
||||
}
|
||||
|
||||
if s.Permissions >= authmiddleware.PermSupport {
|
||||
permList = append(permList, "support")
|
||||
}
|
||||
|
||||
if s.Permissions >= authmiddleware.PermSuperuser {
|
||||
permList = append(permList, "superuser")
|
||||
}
|
||||
|
||||
return c.JSON(permList)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue