add a simple auth function
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
e1aff8d16b
commit
87fe581353
10 changed files with 206 additions and 8 deletions
|
|
@ -25,7 +25,10 @@ func (h *CloneHandler) StartClone(w http.ResponseWriter, r *http.Request) {
|
|||
Error(w, http.StatusBadRequest, "invalid id")
|
||||
return
|
||||
}
|
||||
|
||||
if err := Authorize(r.Context(), ActionCloneStart, repoID); err != nil {
|
||||
Error(w, http.StatusForbidden, "forbidden")
|
||||
return
|
||||
}
|
||||
jobID, err := h.svc.StartClone(r.Context(), repoID)
|
||||
if errors.Is(err, store.ErrNotFound) {
|
||||
Error(w, http.StatusNotFound, "repo not found")
|
||||
|
|
@ -49,7 +52,10 @@ func (h *CloneHandler) GetStatus(w http.ResponseWriter, r *http.Request) {
|
|||
Error(w, http.StatusBadRequest, "invalid id")
|
||||
return
|
||||
}
|
||||
|
||||
if err := Authorize(r.Context(), ActionCloneRead, repoID); err != nil {
|
||||
Error(w, http.StatusForbidden, "forbidden")
|
||||
return
|
||||
}
|
||||
job, err := h.svc.GetLatestCloneJob(r.Context(), repoID)
|
||||
if errors.Is(err, store.ErrNotFound) {
|
||||
Error(w, http.StatusNotFound, "no clone job found for this repo")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue