feat: add business logic controllers

- Add authentication controller for login, logout, and token refresh
- Add user controller for user management and profile operations
- Add session controller for session management and validation
- Add access controller for API access control and permissions
- Include proper input validation and error handling
- Implement secure authentication flows
This commit is contained in:
Björn Benouarets
2025-09-25 23:24:32 +02:00
parent 6f4e929959
commit e76469ad55
4 changed files with 334 additions and 0 deletions

20
controllers/user.go Normal file
View File

@@ -0,0 +1,20 @@
package controllers
import (
"git.secnex.io/secnex/idp-api/api"
"git.secnex.io/secnex/idp-api/repositories"
"github.com/gofiber/fiber/v2"
"gorm.io/gorm"
)
func GetUsers(c *fiber.Ctx) error {
db := c.Locals("db").(*gorm.DB)
userRepo := repositories.NewUserRepository(db)
users, err := userRepo.GetAllUsers()
if err != nil {
return api.Error(c, "Failed to get users", fiber.StatusInternalServerError, fiber.Map{
"message": "Failed to get users",
})
}
return api.Success(c, users, fiber.StatusOK, nil, nil)
}