mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-27 19:00:35 +00:00
removed User checks from handler because middlware has our back
This commit is contained in:
parent
598c553c3f
commit
839b578228
2 changed files with 8 additions and 36 deletions
|
@ -90,9 +90,11 @@ func PostHook(c web.C, w http.ResponseWriter, r *http.Request) {
|
|||
PullRequest: hook.PullRequest,
|
||||
Timestamp: hook.Timestamp,
|
||||
Message: hook.Message,
|
||||
Config: string(yml)}
|
||||
Config: string(yml),
|
||||
}
|
||||
commit.SetAuthor(hook.Author)
|
||||
// inser the commit into the database
|
||||
|
||||
// inserts the commit into the database
|
||||
if err := datastore.PostCommit(ctx, &commit); err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
|
|
|
@ -17,15 +17,7 @@ import (
|
|||
//
|
||||
func GetUserList(c web.C, w http.ResponseWriter, r *http.Request) {
|
||||
var ctx = context.FromC(c)
|
||||
var user = ToUser(c)
|
||||
switch {
|
||||
case user == nil:
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
case user.Admin == false:
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
users, err := datastore.GetUserList(ctx)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
|
@ -47,14 +39,7 @@ func GetUser(c web.C, w http.ResponseWriter, r *http.Request) {
|
|||
host = c.URLParams["host"]
|
||||
login = c.URLParams["login"]
|
||||
)
|
||||
switch {
|
||||
case user == nil:
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
case user.Admin == false:
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
user, err := datastore.GetUserLogin(ctx, host, login)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
|
@ -72,18 +57,10 @@ func GetUser(c web.C, w http.ResponseWriter, r *http.Request) {
|
|||
func PostUser(c web.C, w http.ResponseWriter, r *http.Request) {
|
||||
var ctx = context.FromC(c)
|
||||
var (
|
||||
user = ToUser(c)
|
||||
host = c.URLParams["host"]
|
||||
login = c.URLParams["login"]
|
||||
)
|
||||
switch {
|
||||
case user == nil:
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
case user.Admin == false:
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
account := model.NewUser(host, login, "")
|
||||
if err := datastore.PostUser(ctx, account); err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
|
@ -105,14 +82,7 @@ func DelUser(c web.C, w http.ResponseWriter, r *http.Request) {
|
|||
host = c.URLParams["host"]
|
||||
login = c.URLParams["login"]
|
||||
)
|
||||
switch {
|
||||
case user == nil:
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
return
|
||||
case user.Admin == false:
|
||||
w.WriteHeader(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
||||
account, err := datastore.GetUserLogin(ctx, host, login)
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
|
|
Loading…
Reference in a new issue