fmt + lint
This commit is contained in:
parent
4ae95c1333
commit
6f5cf55e42
3 changed files with 5 additions and 5 deletions
|
@ -51,6 +51,7 @@ func (user *User) IsNamespaceAdmin(namespace *Namespace) (err error) {
|
||||||
return ErrUserNeedsToBeNamespaceAdmin{UserID: user.ID, NamespaceID: namespace.ID}
|
return ErrUserNeedsToBeNamespaceAdmin{UserID: user.ID, NamespaceID: namespace.ID}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsAdmin returns true or false if the user is admin on that namespace or not
|
||||||
func (n *Namespace) IsAdmin(user *User) bool {
|
func (n *Namespace) IsAdmin(user *User) bool {
|
||||||
|
|
||||||
// Owners always have admin rights
|
// Owners always have admin rights
|
||||||
|
|
|
@ -4,7 +4,7 @@ package models
|
||||||
func (n *Namespace) Create(doer *User, _ int64) (err error) {
|
func (n *Namespace) Create(doer *User, _ int64) (err error) {
|
||||||
// Check if we have at least a name
|
// Check if we have at least a name
|
||||||
if n.Name == "" {
|
if n.Name == "" {
|
||||||
return ErrNamespaceNameCannotBeEmpty{NamespaceID:0, UserID:doer.ID}
|
return ErrNamespaceNameCannotBeEmpty{NamespaceID: 0, UserID: doer.ID}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the User exists
|
// Check if the User exists
|
||||||
|
@ -23,7 +23,7 @@ func (n *Namespace) Create(doer *User, _ int64) (err error) {
|
||||||
func (n *Namespace) Update(id int64, doer *User) (err error) {
|
func (n *Namespace) Update(id int64, doer *User) (err error) {
|
||||||
// Check if we have at least a name
|
// Check if we have at least a name
|
||||||
if n.Name == "" {
|
if n.Name == "" {
|
||||||
return ErrNamespaceNameCannotBeEmpty{NamespaceID:id, UserID:doer.ID}
|
return ErrNamespaceNameCannotBeEmpty{NamespaceID: id, UserID: doer.ID}
|
||||||
}
|
}
|
||||||
n.ID = id
|
n.ID = id
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ func (n *Namespace) Update(id int64, doer *User) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !currentNamespace.IsAdmin(&user) {
|
if !currentNamespace.IsAdmin(&user) {
|
||||||
return ErrNeedToBeNamespaceAdmin{NamespaceID:id, UserID:doer.ID}
|
return ErrNeedToBeNamespaceAdmin{NamespaceID: id, UserID: doer.ID}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do the actual update
|
// Do the actual update
|
||||||
|
|
|
@ -32,7 +32,6 @@ func (c *WebHandler) UpdateWeb(ctx echo.Context) error {
|
||||||
return echo.NewHTTPError(http.StatusForbidden, "You need to be list admin to do that.")
|
return echo.NewHTTPError(http.StatusForbidden, "You need to be list admin to do that.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if models.IsErrNamespaceDoesNotExist(err) {
|
if models.IsErrNamespaceDoesNotExist(err) {
|
||||||
return echo.NewHTTPError(http.StatusNotFound, "The namespace does not exist.")
|
return echo.NewHTTPError(http.StatusNotFound, "The namespace does not exist.")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue