Просмотр исходного кода

[Doi] Repo admin-ibility needs to be tested

cgars 7 лет назад
Родитель
Сommit
156fe2969e
2 измененных файлов с 7 добавлено и 1 удалено
  1. 1 1
      Dockerfile.rpi
  2. 6 0
      routes/doi.go

+ 1 - 1
Dockerfile.rpi

@@ -9,7 +9,7 @@ RUN apt-get update &&                                   \
                        git git-annex openssh-server     \
                        python-pip python-setuptools     \
                        socat tzdata patch    \
-                       libpam0g-dev \
+
     && rm -rf /var/lib/apt/lists/*
 
 RUN pip install supervisor pyyaml

+ 6 - 0
routes/doi.go

@@ -4,9 +4,15 @@ import (
 	"github.com/G-Node/gogs/pkg/context"
 	"github.com/G-Node/gogs/pkg/setting"
 	"fmt"
+	"net/http"
 )
 
 func RequestDoi(c *context.Context) {
+	if !c.Repo.IsAdmin(){
+		c.Status(http.StatusUnauthorized)
+		return
+	}
+
 	token := c.GetCookie(setting.SessionConfig.CookieName)
 	c.Redirect(fmt.Sprintf("https://doi.gin.g-node.org/?repo=%s&user=%s&token=%s", c.Repo.Repository.FullName(),
 		c.User.Name, token))