filter tasks for user
This commit is contained in:
parent
30ed1c3cb5
commit
55fc355abf
2 changed files with 4 additions and 3 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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})
|
||||
}
|
||||
})
|
||||
|
|
Reference in a new issue