Give meaningful messages when retag forbided

Signed-off-by: cd1989 <chende@caicloud.io>
This commit is contained in:
cd1989 2018-12-06 16:25:21 +08:00
parent 9100dfdb5f
commit caf07a96fe
2 changed files with 5 additions and 5 deletions

View File

@ -61,9 +61,9 @@ func (b *BaseAPI) HandleUnauthorized() {
}
// HandleForbidden ...
func (b *BaseAPI) HandleForbidden(username string) {
log.Infof("forbidden: %s", username)
b.RenderError(http.StatusForbidden, "")
func (b *BaseAPI) HandleForbidden(text string) {
log.Infof("forbidden: %s", text)
b.RenderError(http.StatusForbidden, text)
}
// HandleBadRequest ...

View File

@ -480,14 +480,14 @@ func (ra *RepositoryAPI) Retag() {
// Check whether use has read permission to source project
if !ra.SecurityCtx.HasReadPerm(srcImage.Project) {
log.Errorf("user has no read permission to project '%s'", srcImage.Project)
ra.HandleForbidden(ra.SecurityCtx.GetUsername())
ra.HandleForbidden(fmt.Sprintf("%s has no read permission to project %s", ra.SecurityCtx.GetUsername(), srcImage.Project))
return
}
// Check whether user has write permission to target project
if !ra.SecurityCtx.HasWritePerm(project) {
log.Errorf("user has no write permission to project '%s'", project)
ra.HandleForbidden(ra.SecurityCtx.GetUsername())
ra.HandleForbidden(fmt.Sprintf("%s has no write permission to project %s", ra.SecurityCtx.GetUsername(), project))
return
}