27 lines
528 B
Go
27 lines
528 B
Go
package handlers
|
|
|
|
import (
|
|
"authorization/helper"
|
|
"authorization/models"
|
|
"authorization/services"
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
func AuthorizeHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
|
var request models.AuthorizationRequest
|
|
|
|
err := json.NewDecoder(r.Body).Decode(&request)
|
|
if err != nil {
|
|
helper.RespondWithError(w, http.StatusBadRequest, "Invalid request payload")
|
|
return
|
|
}
|
|
|
|
allowed := services.Authorize()
|
|
if !allowed {
|
|
helper.RespondWithError(w, http.StatusForbidden, "Access denied")
|
|
return
|
|
}
|
|
}
|