diff options
author | zeripath <art27@cantab.net> | 2021-04-06 20:44:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-06 20:44:05 +0100 |
commit | fa3895ce81ba64689fbf76b91d96963541547881 (patch) | |
tree | d7fe6c24429ccbb1d55b53441cefb34799dee993 /routers/user/setting | |
parent | 8be2cc4fc72e7985640dabdddb06cf78169c1882 (diff) | |
download | gitea-fa3895ce81ba64689fbf76b91d96963541547881.tar.gz gitea-fa3895ce81ba64689fbf76b91d96963541547881.zip |
Move modules/forms to services/forms (#15305)
Forms are dependent on models and therefore should be in services.
This PR also removes the old auth. aliasing
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'routers/user/setting')
-rw-r--r-- | routers/user/setting/account.go | 8 | ||||
-rw-r--r-- | routers/user/setting/account_test.go | 4 | ||||
-rw-r--r-- | routers/user/setting/applications.go | 4 | ||||
-rw-r--r-- | routers/user/setting/keys.go | 4 | ||||
-rw-r--r-- | routers/user/setting/oauth2.go | 6 | ||||
-rw-r--r-- | routers/user/setting/profile.go | 10 | ||||
-rw-r--r-- | routers/user/setting/security_openid.go | 8 | ||||
-rw-r--r-- | routers/user/setting/security_twofa.go | 4 | ||||
-rw-r--r-- | routers/user/setting/security_u2f.go | 6 |
9 files changed, 27 insertions, 27 deletions
diff --git a/routers/user/setting/account.go b/routers/user/setting/account.go index 2b2804b53b..e12d63ee02 100644 --- a/routers/user/setting/account.go +++ b/routers/user/setting/account.go @@ -13,12 +13,12 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" - auth "code.gitea.io/gitea/modules/forms" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/password" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/web" + "code.gitea.io/gitea/services/forms" "code.gitea.io/gitea/services/mailer" ) @@ -39,7 +39,7 @@ func Account(ctx *context.Context) { // AccountPost response for change user's password func AccountPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.ChangePasswordForm) + form := web.GetForm(ctx).(*forms.ChangePasswordForm) ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsAccount"] = true @@ -84,7 +84,7 @@ func AccountPost(ctx *context.Context) { // EmailPost response for change user's email func EmailPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.AddEmailForm) + form := web.GetForm(ctx).(*forms.AddEmailForm) ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsAccount"] = true @@ -257,7 +257,7 @@ func DeleteAccount(ctx *context.Context) { // UpdateUIThemePost is used to update users' specific theme func UpdateUIThemePost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.UpdateThemeForm) + form := web.GetForm(ctx).(*forms.UpdateThemeForm) ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsAccount"] = true diff --git a/routers/user/setting/account_test.go b/routers/user/setting/account_test.go index 0e7e147b8b..25b68da762 100644 --- a/routers/user/setting/account_test.go +++ b/routers/user/setting/account_test.go @@ -9,10 +9,10 @@ import ( "testing" "code.gitea.io/gitea/models" - auth "code.gitea.io/gitea/modules/forms" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/test" "code.gitea.io/gitea/modules/web" + "code.gitea.io/gitea/services/forms" "github.com/stretchr/testify/assert" ) @@ -86,7 +86,7 @@ func TestChangePassword(t *testing.T) { test.LoadUser(t, ctx, 2) test.LoadRepo(t, ctx, 1) - web.SetForm(ctx, &auth.ChangePasswordForm{ + web.SetForm(ctx, &forms.ChangePasswordForm{ OldPassword: req.OldPassword, Password: req.NewPassword, Retype: req.Retype, diff --git a/routers/user/setting/applications.go b/routers/user/setting/applications.go index 367f2b38c1..4161efdea4 100644 --- a/routers/user/setting/applications.go +++ b/routers/user/setting/applications.go @@ -11,9 +11,9 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" - auth "code.gitea.io/gitea/modules/forms" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/web" + "code.gitea.io/gitea/services/forms" ) const ( @@ -32,7 +32,7 @@ func Applications(ctx *context.Context) { // ApplicationsPost response for add user's access token func ApplicationsPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.NewAccessTokenForm) + form := web.GetForm(ctx).(*forms.NewAccessTokenForm) ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsApplications"] = true diff --git a/routers/user/setting/keys.go b/routers/user/setting/keys.go index 98b7b74137..e56a33afcb 100644 --- a/routers/user/setting/keys.go +++ b/routers/user/setting/keys.go @@ -11,9 +11,9 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" - auth "code.gitea.io/gitea/modules/forms" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/web" + "code.gitea.io/gitea/services/forms" ) const ( @@ -35,7 +35,7 @@ func Keys(ctx *context.Context) { // KeysPost response for change user's SSH/GPG keys func KeysPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.AddKeyForm) + form := web.GetForm(ctx).(*forms.AddKeyForm) ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsKeys"] = true ctx.Data["DisableSSH"] = setting.SSH.Disabled diff --git a/routers/user/setting/oauth2.go b/routers/user/setting/oauth2.go index a12f4dc1ba..c8db6e87f2 100644 --- a/routers/user/setting/oauth2.go +++ b/routers/user/setting/oauth2.go @@ -11,10 +11,10 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" - auth "code.gitea.io/gitea/modules/forms" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/web" + "code.gitea.io/gitea/services/forms" ) const ( @@ -23,7 +23,7 @@ const ( // OAuthApplicationsPost response for adding a oauth2 application func OAuthApplicationsPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.EditOAuth2ApplicationForm) + form := web.GetForm(ctx).(*forms.EditOAuth2ApplicationForm) ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsApplications"] = true @@ -55,7 +55,7 @@ func OAuthApplicationsPost(ctx *context.Context) { // OAuthApplicationsEdit response for editing oauth2 application func OAuthApplicationsEdit(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.EditOAuth2ApplicationForm) + form := web.GetForm(ctx).(*forms.EditOAuth2ApplicationForm) ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsApplications"] = true diff --git a/routers/user/setting/profile.go b/routers/user/setting/profile.go index c04428261a..0bc2b4ee36 100644 --- a/routers/user/setting/profile.go +++ b/routers/user/setting/profile.go @@ -17,12 +17,12 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" - auth "code.gitea.io/gitea/modules/forms" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/modules/web/middleware" + "code.gitea.io/gitea/services/forms" "github.com/unknwon/i18n" ) @@ -75,7 +75,7 @@ func HandleUsernameChange(ctx *context.Context, user *models.User, newName strin // ProfilePost response for change user's profile func ProfilePost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.UpdateProfileForm) + form := web.GetForm(ctx).(*forms.UpdateProfileForm) ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsProfile"] = true @@ -127,8 +127,8 @@ func ProfilePost(ctx *context.Context) { // UpdateAvatarSetting update user's avatar // FIXME: limit size. -func UpdateAvatarSetting(ctx *context.Context, form *auth.AvatarForm, ctxUser *models.User) error { - ctxUser.UseCustomAvatar = form.Source == auth.AvatarLocal +func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser *models.User) error { + ctxUser.UseCustomAvatar = form.Source == forms.AvatarLocal if len(form.Gravatar) > 0 { if form.Avatar != nil { ctxUser.Avatar = base.EncodeMD5(form.Gravatar) @@ -176,7 +176,7 @@ func UpdateAvatarSetting(ctx *context.Context, form *auth.AvatarForm, ctxUser *m // AvatarPost response for change user's avatar request func AvatarPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.AvatarForm) + form := web.GetForm(ctx).(*forms.AvatarForm) if err := UpdateAvatarSetting(ctx, form, ctx.User); err != nil { ctx.Flash.Error(err.Error()) } else { diff --git a/routers/user/setting/security_openid.go b/routers/user/setting/security_openid.go index c5d106e990..74dba12825 100644 --- a/routers/user/setting/security_openid.go +++ b/routers/user/setting/security_openid.go @@ -10,15 +10,15 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/auth/openid" "code.gitea.io/gitea/modules/context" - auth "code.gitea.io/gitea/modules/forms" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/web" + "code.gitea.io/gitea/services/forms" ) // OpenIDPost response for change user's openid func OpenIDPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.AddOpenIDForm) + form := web.GetForm(ctx).(*forms.AddOpenIDForm) ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsSecurity"] = true @@ -81,7 +81,7 @@ func settingsOpenIDVerify(ctx *context.Context) { id, err := openid.Verify(fullURL) if err != nil { - ctx.RenderWithErr(err.Error(), tplSettingsSecurity, &auth.AddOpenIDForm{ + ctx.RenderWithErr(err.Error(), tplSettingsSecurity, &forms.AddOpenIDForm{ Openid: id, }) return @@ -92,7 +92,7 @@ func settingsOpenIDVerify(ctx *context.Context) { oid := &models.UserOpenID{UID: ctx.User.ID, URI: id} if err = models.AddUserOpenID(oid); err != nil { if models.IsErrOpenIDAlreadyUsed(err) { - ctx.RenderWithErr(ctx.Tr("form.openid_been_used", id), tplSettingsSecurity, &auth.AddOpenIDForm{Openid: id}) + ctx.RenderWithErr(ctx.Tr("form.openid_been_used", id), tplSettingsSecurity, &forms.AddOpenIDForm{Openid: id}) return } ctx.ServerError("AddUserOpenID", err) diff --git a/routers/user/setting/security_twofa.go b/routers/user/setting/security_twofa.go index a830495f54..7b08a05939 100644 --- a/routers/user/setting/security_twofa.go +++ b/routers/user/setting/security_twofa.go @@ -15,10 +15,10 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" - auth "code.gitea.io/gitea/modules/forms" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/web" + "code.gitea.io/gitea/services/forms" "github.com/pquerna/otp" "github.com/pquerna/otp/totp" @@ -168,7 +168,7 @@ func EnrollTwoFactor(ctx *context.Context) { // EnrollTwoFactorPost handles enrolling the user into 2FA. func EnrollTwoFactorPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.TwoFactorAuthForm) + form := web.GetForm(ctx).(*forms.TwoFactorAuthForm) ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsSecurity"] = true diff --git a/routers/user/setting/security_u2f.go b/routers/user/setting/security_u2f.go index 040af34b5b..f9e35549fb 100644 --- a/routers/user/setting/security_u2f.go +++ b/routers/user/setting/security_u2f.go @@ -10,17 +10,17 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" - auth "code.gitea.io/gitea/modules/forms" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/web" + "code.gitea.io/gitea/services/forms" "github.com/tstranex/u2f" ) // U2FRegister initializes the u2f registration procedure func U2FRegister(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.U2FRegistrationForm) + form := web.GetForm(ctx).(*forms.U2FRegistrationForm) if form.Name == "" { ctx.Error(http.StatusConflict) return @@ -87,7 +87,7 @@ func U2FRegisterPost(ctx *context.Context) { // U2FDelete deletes an security key by id func U2FDelete(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.U2FDeleteForm) + form := web.GetForm(ctx).(*forms.U2FDeleteForm) reg, err := models.GetU2FRegistrationByID(form.ID) if err != nil { if models.IsErrU2FRegistrationNotExist(err) { |