123456789101112131415161718192021222324252627282930 |
- package login
- import (
- "context"
- "net/http"
- "../../../core/errorHandler"
- "../../../core/response"
- "../../lib/auth"
- )
- func Mandatory(w http.ResponseWriter, r *http.Request) (logged bool) {
- user, logged := auth.GetUser(r)
- if !logged {
- var Errors errorHandler.Errors
- Errors.ActionForbidden("User must be logged in")
- response.JSON(Errors)
- } else {
- ctx := context.WithValue(r.Context(), "user", user)
- r = r.WithContext(ctx)
- }
- return
- }
|