Changed so that username is required to get projects, so that you can get another user's projects (for admin stuff)
This commit is contained in:
parent
4ab23b3c3c
commit
8b6462abee
3 changed files with 12 additions and 21 deletions
|
@ -4,15 +4,16 @@ import (
|
|||
db "ttime/internal/database"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
"github.com/gofiber/fiber/v2/log"
|
||||
)
|
||||
|
||||
// GetUserProjects returns all projects that the user is a member of
|
||||
func GetUserProjects(c *fiber.Ctx) error {
|
||||
// First we get the username from the token
|
||||
user := c.Locals("user").(*jwt.Token)
|
||||
claims := user.Claims.(jwt.MapClaims)
|
||||
username := claims["name"].(string)
|
||||
username := c.Params("username")
|
||||
if username == "" {
|
||||
log.Info("No username provided")
|
||||
return c.Status(400).SendString("No username provided")
|
||||
}
|
||||
|
||||
// Then dip into the database to get the projects
|
||||
projects, err := db.GetDb(c).GetProjectsForUser(username)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue