1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Rename ctx.Form() to ctx.FormString() and move code into own file (#16571)

Followup from #16562 prepare for #16567

* Rename ctx.Form() to ctx.FormString()
* Reimplement FormX func to need less code and cpu cycles
* Move code into own file
This commit is contained in:
6543
2021-08-11 02:31:13 +02:00
committed by GitHub
parent 2eeae4edb6
commit c4d70a0325
64 changed files with 236 additions and 449 deletions

View File

@@ -90,7 +90,7 @@ func EmailPost(ctx *context.Context) {
ctx.Data["PageIsSettingsAccount"] = true
// Make emailaddress primary.
if ctx.Form("_method") == "PRIMARY" {
if ctx.FormString("_method") == "PRIMARY" {
if err := models.MakeEmailPrimary(&models.EmailAddress{ID: ctx.FormInt64("id")}); err != nil {
ctx.ServerError("MakeEmailPrimary", err)
return
@@ -101,7 +101,7 @@ func EmailPost(ctx *context.Context) {
return
}
// Send activation Email
if ctx.Form("_method") == "SENDACTIVATION" {
if ctx.FormString("_method") == "SENDACTIVATION" {
var address string
if ctx.Cache.IsExist("MailResendLimit_" + ctx.User.LowerName) {
log.Error("Send activation: activation still pending")
@@ -147,8 +147,8 @@ func EmailPost(ctx *context.Context) {
return
}
// Set Email Notification Preference
if ctx.Form("_method") == "NOTIFICATION" {
preference := ctx.Form("preference")
if ctx.FormString("_method") == "NOTIFICATION" {
preference := ctx.FormString("preference")
if !(preference == models.EmailNotificationsEnabled ||
preference == models.EmailNotificationsOnMention ||
preference == models.EmailNotificationsDisabled) {
@@ -229,7 +229,7 @@ func DeleteAccount(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsAccount"] = true
if _, err := auth.UserSignIn(ctx.User.Name, ctx.Form("password")); err != nil {
if _, err := auth.UserSignIn(ctx.User.Name, ctx.FormString("password")); err != nil {
if models.IsErrUserNotExist(err) {
loadAccountData(ctx)

View File

@@ -23,8 +23,8 @@ func AdoptOrDeleteRepository(ctx *context.Context) {
allowDelete := ctx.IsUserSiteAdmin() || setting.Repository.AllowDeleteOfUnadoptedRepositories
ctx.Data["allowDelete"] = allowDelete
dir := ctx.Form("id")
action := ctx.Form("action")
dir := ctx.FormString("id")
action := ctx.FormString("action")
ctxUser := ctx.User
root := filepath.Join(models.UserPath(ctxUser.LowerName))

View File

@@ -193,7 +193,7 @@ func KeysPost(ctx *context.Context) {
// DeleteKey response for delete user's SSH/GPG key
func DeleteKey(ctx *context.Context) {
switch ctx.Form("type") {
switch ctx.FormString("type") {
case "gpg":
if err := models.DeleteGPGKey(ctx.User, ctx.FormInt64("id")); err != nil {
ctx.Flash.Error("DeleteGPGKey: " + err.Error())
@@ -265,5 +265,5 @@ func loadKeysData(ctx *context.Context) {
}
ctx.Data["Principals"] = principals
ctx.Data["VerifyingID"] = ctx.Form("verify_gpg")
ctx.Data["VerifyingID"] = ctx.FormString("verify_gpg")
}

View File

@@ -25,7 +25,7 @@ func Security(ctx *context.Context) {
ctx.Data["PageIsSettingsSecurity"] = true
ctx.Data["RequireU2F"] = true
if ctx.Form("openid.return_to") != "" {
if ctx.FormString("openid.return_to") != "" {
settingsOpenIDVerify(ctx)
return
}