From 88da7a7174f9c1568cc2d8d084d6b05a8d268690 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sun, 2 Jan 2022 02:38:07 +0000 Subject: [PATCH] Use correct user when determining max repo limits for error messages (#18153) - Use the correct user(`owner` instead of `ctx.User`) to get the maxCreationLimit. --- routers/web/repo/migrate.go | 2 +- routers/web/repo/repo.go | 2 +- routers/web/repo/setting.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/web/repo/migrate.go b/routers/web/repo/migrate.go index 9b12653839..1bbb192b24 100644 --- a/routers/web/repo/migrate.go +++ b/routers/web/repo/migrate.go @@ -82,7 +82,7 @@ func handleMigrateError(ctx *context.Context, owner *user_model.User, err error, ctx.RenderWithErr(ctx.Tr("form.2fa_auth_required"), tpl, form) case repo_model.IsErrReachLimitOfRepo(err): var msg string - maxCreationLimit := ctx.User.MaxCreationLimit() + maxCreationLimit := owner.MaxCreationLimit() if maxCreationLimit == 1 { msg = ctx.Tr("repo.form.reach_limit_of_creation_1", maxCreationLimit) } else { diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index 0d8c6d374f..8e0998225a 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -163,7 +163,7 @@ func handleCreateError(ctx *context.Context, owner *user_model.User, err error, switch { case repo_model.IsErrReachLimitOfRepo(err): var msg string - maxCreationLimit := ctx.User.MaxCreationLimit() + maxCreationLimit := owner.MaxCreationLimit() if maxCreationLimit == 1 { msg = ctx.Tr("repo.form.reach_limit_of_creation_1", maxCreationLimit) } else { diff --git a/routers/web/repo/setting.go b/routers/web/repo/setting.go index 5457e651d3..57a195ee62 100644 --- a/routers/web/repo/setting.go +++ b/routers/web/repo/setting.go @@ -609,7 +609,7 @@ func SettingsPost(ctx *context.Context) { } if !ctx.Repo.Owner.CanCreateRepo() { - maxCreationLimit := ctx.User.MaxCreationLimit() + maxCreationLimit := ctx.Repo.Owner.MaxCreationLimit() if maxCreationLimit == 1 { ctx.Flash.Error(ctx.Tr("repo.form.reach_limit_of_creation_1", maxCreationLimit)) } else {