diff --git a/conf/locale/TRANSLATORS b/conf/locale/TRANSLATORS index 733c4ef435..75424b666b 100644 --- a/conf/locale/TRANSLATORS +++ b/conf/locale/TRANSLATORS @@ -4,7 +4,9 @@ Akihiro YAGASAKI Alexander Steinhöfer Christoph Kisfeld +Daniel Speichert Huimin Wang +ilko Thomas Fanninger Łukasz Jan Niemier Lafriks diff --git a/gogs.go b/gogs.go index 2405d44285..b6a8130d3f 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.6.1.0716 Beta" +const APP_VER = "0.6.1.0719 Beta" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 5e6a2e0d20..cd231ccd62 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -28,18 +28,25 @@ const ( FORK base.TplName = "repo/fork" ) -func checkContextUser(ctx *middleware.Context, uid int64) (*models.User, error) { - ctxUser := ctx.User - if uid > 0 { - org, err := models.GetUserById(uid) - if err != models.ErrUserNotExist { - if err != nil { - return nil, fmt.Errorf("GetUserById: %v", err) - } - ctxUser = org - } +func checkContextUser(ctx *middleware.Context, uid int64) *models.User { + // Not equal means current user is an organization. + if uid == ctx.User.Id || uid == 0 { + return ctx.User } - return ctxUser, nil + + org, err := models.GetUserById(uid) + if err == models.ErrUserNotExist { + return ctx.User + } + + if err != nil { + ctx.Handle(500, "checkContextUser", fmt.Errorf("GetUserById(%d): %v", uid, err)) + return nil + } else if !org.IsOrganization() { + ctx.Error(403) + return nil + } + return org } func Create(ctx *middleware.Context) { @@ -51,9 +58,8 @@ func Create(ctx *middleware.Context) { ctx.Data["Gitignores"] = models.Gitignores ctx.Data["Licenses"] = models.Licenses - ctxUser, err := checkContextUser(ctx, ctx.QueryInt64("org")) - if err != nil { - ctx.Handle(500, "checkContextUser", err) + ctxUser := checkContextUser(ctx, ctx.QueryInt64("org")) + if ctx.Written() { return } ctx.Data["ContextUser"] = ctxUser @@ -73,15 +79,9 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) { ctx.Data["Gitignores"] = models.Gitignores ctx.Data["Licenses"] = models.Licenses - ctxUser := ctx.User - // Not equal means current user is an organization. - if form.Uid != ctx.User.Id { - var err error - ctxUser, err = checkContextUser(ctx, form.Uid) - if err != nil { - ctx.Handle(500, "checkContextUser", err) - return - } + ctxUser := checkContextUser(ctx, form.Uid) + if ctx.Written() { + return } ctx.Data["ContextUser"] = ctxUser @@ -136,9 +136,8 @@ func CreatePost(ctx *middleware.Context, form auth.CreateRepoForm) { func Migrate(ctx *middleware.Context) { ctx.Data["Title"] = ctx.Tr("new_migrate") - ctxUser, err := checkContextUser(ctx, ctx.QueryInt64("org")) - if err != nil { - ctx.Handle(500, "checkContextUser", err) + ctxUser := checkContextUser(ctx, ctx.QueryInt64("org")) + if ctx.Written() { return } ctx.Data["ContextUser"] = ctxUser @@ -155,15 +154,9 @@ func Migrate(ctx *middleware.Context) { func MigratePost(ctx *middleware.Context, form auth.MigrateRepoForm) { ctx.Data["Title"] = ctx.Tr("new_migrate") - ctxUser := ctx.User - // Not equal means current user is an organization. - if form.Uid != ctx.User.Id { - var err error - ctxUser, err = checkContextUser(ctx, form.Uid) - if err != nil { - ctx.Handle(500, "checkContextUser", err) - return - } + ctxUser := checkContextUser(ctx, form.Uid) + if ctx.Written() { + return } ctx.Data["ContextUser"] = ctxUser @@ -297,15 +290,9 @@ func ForkPost(ctx *middleware.Context, form auth.CreateRepoForm) { return } - ctxUser := ctx.User - // Not equal means current user is an organization. - if form.Uid != ctx.User.Id { - var err error - ctxUser, err = checkContextUser(ctx, form.Uid) - if err != nil { - ctx.Handle(500, "checkContextUser", err) - return - } + ctxUser := checkContextUser(ctx, form.Uid) + if ctx.Written() { + return } ctx.Data["ContextUser"] = ctxUser diff --git a/templates/.VERSION b/templates/.VERSION index 345625af85..e87964c1ef 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.6.1.0716 Beta \ No newline at end of file +0.6.1.0719 Beta \ No newline at end of file