diff --git a/Lab01/app/database/database.go b/Lab01/app/database/database.go index 014d6ae..d968401 100644 --- a/Lab01/app/database/database.go +++ b/Lab01/app/database/database.go @@ -28,9 +28,9 @@ func (db *Database) Initialize() { db.ORM = orm } -func (db *Database) GetAllTasks() []Task { +func (db *Database) GetAllTasks(username string) []Task { var tasks []Task - db.ORM.Find(&tasks) + db.ORM.Where("username = ?", username).Find(&tasks) return tasks } diff --git a/Lab01/app/webpage/webpage.go b/Lab01/app/webpage/webpage.go index 4646945..540511b 100644 --- a/Lab01/app/webpage/webpage.go +++ b/Lab01/app/webpage/webpage.go @@ -39,7 +39,8 @@ func (wp *Webpage) defineRoutes() { { tasks.GET("", func(c *gin.Context) { if wp.isLoggedInMiddleware(c) { - tasks := wp.Database.GetAllTasks() + username := c.Request.Header.Get("username") + tasks := wp.Database.GetAllTasks(username) c.JSON(200, gin.H{"tasks": tasks}) } })