mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender.git
synced 2026-01-18 20:42:26 +01:00
feat: Add new data-manager service for professor and module management and a new frontend application with i18n and a professor dashboard.
This commit is contained in:
29
services/data-manager/service/professor/routes.go
Normal file
29
services/data-manager/service/professor/routes.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package professor
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/pocketbase/pocketbase/apis"
|
||||
"github.com/pocketbase/pocketbase/core"
|
||||
)
|
||||
|
||||
func RegisterRoutes(se *core.ServeEvent, service *ProfessorService) {
|
||||
se.Router.GET("/api/professor/modules", func(e *core.RequestEvent) error {
|
||||
record := e.Auth
|
||||
if record == nil {
|
||||
return apis.NewForbiddenError("Only authenticated users can access this endpoint", nil)
|
||||
}
|
||||
|
||||
email := record.GetString("email")
|
||||
if email == "" {
|
||||
return apis.NewBadRequestError("User has no email", nil)
|
||||
}
|
||||
|
||||
modules, err := service.GetModulesForProfessor(email)
|
||||
if err != nil {
|
||||
return apis.NewBadRequestError("Failed to fetch modules", err)
|
||||
}
|
||||
|
||||
return e.JSON(http.StatusOK, modules)
|
||||
}).Bind(apis.RequireAuth())
|
||||
}
|
||||
Reference in New Issue
Block a user