Add auth param to all methods

This commit is contained in:
kolaente 2021-01-31 21:10:03 +01:00
parent 588abb7370
commit 26386be9a9
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
5 changed files with 9 additions and 9 deletions

View File

@ -70,10 +70,10 @@ This interface defines methods to Create/Read/ReadAll/Update/Delete something. I
```go
type CRUDable interface {
Create(*xorm.Session, Auth) error
ReadOne(*xorm.Session) error
ReadOne(*xorm.Session, Auth) error
ReadAll(s *xorm.Session, auth Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error)
Update(*xorm.Session) error
Delete(*xorm.Session) error
Update(*xorm.Session, Auth) error
Delete(*xorm.Session, Auth) error
}
```

View File

@ -66,7 +66,7 @@ func (c *WebHandler) DeleteWeb(ctx echo.Context) error {
return echo.NewHTTPError(http.StatusForbidden)
}
err = currentStruct.Delete(s)
err = currentStruct.Delete(s, currentAuth)
if err != nil {
_ = s.Rollback()
return HandleHTTPError(err, ctx)

View File

@ -63,7 +63,7 @@ func (c *WebHandler) ReadOneWeb(ctx echo.Context) error {
}
// Get our object
err = currentStruct.ReadOne(s)
err = currentStruct.ReadOne(s, currentAuth)
if err != nil {
_ = s.Rollback()
return HandleHTTPError(err, ctx)

View File

@ -68,7 +68,7 @@ func (c *WebHandler) UpdateWeb(ctx echo.Context) error {
}
// Do the update
err = currentStruct.Update(s)
err = currentStruct.Update(s, currentAuth)
if err != nil {
_ = s.Rollback()
return HandleHTTPError(err, ctx)

6
web.go
View File

@ -31,10 +31,10 @@ type Rights interface {
// CRUDable defines the crud methods
type CRUDable interface {
Create(*xorm.Session, Auth) error
ReadOne(*xorm.Session) error
ReadOne(*xorm.Session, Auth) error
ReadAll(s *xorm.Session, auth Auth, search string, page int, perPage int) (result interface{}, resultCount int, numberOfTotalItems int64, err error)
Update(*xorm.Session) error
Delete(*xorm.Session) error
Update(*xorm.Session, Auth) error
Delete(*xorm.Session, Auth) error
}
// HTTPErrorProcessor is executed when the defined error is thrown, it will make sure the user sees an appropriate error message and http status code