Add isLoggedIn
This commit is contained in:
parent
c2d3850a33
commit
2dee0c9333
15
handlers/auth/isloggedin.go
Normal file
15
handlers/auth/isloggedin.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package handlers_auth
|
||||||
|
|
||||||
|
import (
|
||||||
|
"brunel/auth"
|
||||||
|
|
||||||
|
"github.com/gofiber/fiber/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
func IsLoggedIn(c *fiber.Ctx) error {
|
||||||
|
ok, _ := auth.CheckSessionToken(c.Cookies("pt"))
|
||||||
|
if !ok {
|
||||||
|
return c.Status(fiber.StatusUnauthorized).SendString("Unauthorized")
|
||||||
|
}
|
||||||
|
return c.Status(fiber.StatusOK).SendString("Logged in")
|
||||||
|
}
|
@ -95,9 +95,10 @@ func runServer(ctx context.Context) error {
|
|||||||
server.Get("/api/package/:package", handlers_packages.Package)
|
server.Get("/api/package/:package", handlers_packages.Package)
|
||||||
server.Get("/api/queue", handlers_build.Queue)
|
server.Get("/api/queue", handlers_build.Queue)
|
||||||
server.Get("/api/errored", handlers_build.Errored)
|
server.Get("/api/errored", handlers_build.Errored)
|
||||||
|
server.Get("/api/isloggedin", handlers_auth.IsLoggedIn)
|
||||||
|
|
||||||
server.Post("/api/login", handlers_auth.Login)
|
server.Post("/api/login", handlers_auth.Login)
|
||||||
adminRoutes.Post("/triggerBuild", handlers_build.TriggerBuild)
|
adminRoutes.Post("/triggerbuild", handlers_build.TriggerBuild)
|
||||||
adminRoutes.Post("/register", handlers_auth.Register)
|
adminRoutes.Post("/register", handlers_auth.Register)
|
||||||
adminRoutes.Post("/updatePassword", handlers_auth.UpdatePassword)
|
adminRoutes.Post("/updatePassword", handlers_auth.UpdatePassword)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user