mirror of
1
Fork 0
This commit is contained in:
Unknwon 2015-07-19 17:11:16 +08:00
parent 03011ed307
commit 42a72b62fc
4 changed files with 35 additions and 46 deletions

View File

@ -4,7 +4,9 @@
Akihiro YAGASAKI <yaggytter@momiage.com>
Alexander Steinhöfer <kontakt@lx-s.de>
Christoph Kisfeld <christoph.kisfeld@gmail.com>
Daniel Speichert <daniel@speichert.pl>
Huimin Wang <wanghm2009@hotmail.co.jp>
ilko <email>
Thomas Fanninger <gogs.thomas@fanninger.at>
Łukasz Jan Niemier <lukasz@niemier.pl>
Lafriks <lafriks@gmail.com>

View File

@ -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())

View File

@ -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 {
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
}
org, err := models.GetUserById(uid)
if err != models.ErrUserNotExist {
if err == models.ErrUserNotExist {
return ctx.User
}
if err != nil {
return nil, fmt.Errorf("GetUserById: %v", err)
ctx.Handle(500, "checkContextUser", fmt.Errorf("GetUserById(%d): %v", uid, err))
return nil
} else if !org.IsOrganization() {
ctx.Error(403)
return nil
}
ctxUser = org
}
}
return ctxUser, 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,16 +79,10 @@ 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)
ctxUser := checkContextUser(ctx, form.Uid)
if ctx.Written() {
return
}
}
ctx.Data["ContextUser"] = ctxUser
if err := ctx.User.GetOrganizations(); err != nil {
@ -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,16 +154,10 @@ 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)
ctxUser := checkContextUser(ctx, form.Uid)
if ctx.Written() {
return
}
}
ctx.Data["ContextUser"] = ctxUser
if err := ctx.User.GetOrganizations(); err != nil {
@ -297,16 +290,10 @@ 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)
ctxUser := checkContextUser(ctx, form.Uid)
if ctx.Written() {
return
}
}
ctx.Data["ContextUser"] = ctxUser
if err := ctx.User.GetOrganizations(); err != nil {

View File

@ -1 +1 @@
0.6.1.0716 Beta
0.6.1.0719 Beta