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 | |
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')
-rw-r--r-- | routers/user/auth.go | 20 | ||||
-rw-r--r-- | routers/user/auth_openid.go | 20 | ||||
-rw-r--r-- | routers/user/oauth.go | 12 | ||||
-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 |
12 files changed, 53 insertions, 53 deletions
diff --git a/routers/user/auth.go b/routers/user/auth.go index a6d3ace7ba..1692a396cc 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -16,7 +16,6 @@ import ( "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/modules/eventsource" - auth "code.gitea.io/gitea/modules/forms" "code.gitea.io/gitea/modules/hcaptcha" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/password" @@ -27,6 +26,7 @@ import ( "code.gitea.io/gitea/modules/web/middleware" "code.gitea.io/gitea/routers/utils" "code.gitea.io/gitea/services/externalaccount" + "code.gitea.io/gitea/services/forms" "code.gitea.io/gitea/services/mailer" "github.com/markbates/goth" @@ -171,7 +171,7 @@ func SignInPost(ctx *context.Context) { return } - form := web.GetForm(ctx).(*auth.SignInForm) + form := web.GetForm(ctx).(*forms.SignInForm) u, err := models.UserSignIn(form.UserName, form.Password) if err != nil { if models.IsErrUserNotExist(err) { @@ -253,7 +253,7 @@ func TwoFactor(ctx *context.Context) { // TwoFactorPost validates a user's two-factor authentication token. func TwoFactorPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.TwoFactorAuthForm) + form := web.GetForm(ctx).(*forms.TwoFactorAuthForm) ctx.Data["Title"] = ctx.Tr("twofa") // Ensure user is in a 2FA session. @@ -309,7 +309,7 @@ func TwoFactorPost(ctx *context.Context) { return } - ctx.RenderWithErr(ctx.Tr("auth.twofa_passcode_incorrect"), tplTwofa, auth.TwoFactorAuthForm{}) + ctx.RenderWithErr(ctx.Tr("auth.twofa_passcode_incorrect"), tplTwofa, forms.TwoFactorAuthForm{}) } // TwoFactorScratch shows the scratch code form for two-factor authentication. @@ -332,7 +332,7 @@ func TwoFactorScratch(ctx *context.Context) { // TwoFactorScratchPost validates and invalidates a user's two-factor scratch token. func TwoFactorScratchPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.TwoFactorScratchAuthForm) + form := web.GetForm(ctx).(*forms.TwoFactorScratchAuthForm) ctx.Data["Title"] = ctx.Tr("twofa_scratch") // Ensure user is in a 2FA session. @@ -375,7 +375,7 @@ func TwoFactorScratchPost(ctx *context.Context) { return } - ctx.RenderWithErr(ctx.Tr("auth.twofa_scratch_token_incorrect"), tplTwofaScratch, auth.TwoFactorScratchAuthForm{}) + ctx.RenderWithErr(ctx.Tr("auth.twofa_scratch_token_incorrect"), tplTwofaScratch, forms.TwoFactorScratchAuthForm{}) } // U2F shows the U2F login page @@ -796,7 +796,7 @@ func LinkAccount(ctx *context.Context) { // LinkAccountPostSignIn handle the coupling of external account with another account using signIn func LinkAccountPostSignIn(ctx *context.Context) { - signInForm := web.GetForm(ctx).(*auth.SignInForm) + signInForm := web.GetForm(ctx).(*forms.SignInForm) ctx.Data["DisablePassword"] = !setting.Service.RequireExternalRegistrationPassword || setting.Service.AllowOnlyExternalRegistration ctx.Data["Title"] = ctx.Tr("link_account") ctx.Data["LinkAccountMode"] = true @@ -881,7 +881,7 @@ func LinkAccountPostSignIn(ctx *context.Context) { // LinkAccountPostRegister handle the creation of a new account for an external account using signUp func LinkAccountPostRegister(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.RegisterForm) + form := web.GetForm(ctx).(*forms.RegisterForm) // TODO Make insecure passwords optional for local accounts also, // once email-based Second-Factor Auth is available ctx.Data["DisablePassword"] = !setting.Service.RequireExternalRegistrationPassword || setting.Service.AllowOnlyExternalRegistration @@ -1089,7 +1089,7 @@ func SignUp(ctx *context.Context) { // SignUpPost response for sign up information submission func SignUpPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.RegisterForm) + form := web.GetForm(ctx).(*forms.RegisterForm) ctx.Data["Title"] = ctx.Tr("sign_up") ctx.Data["SignUpLink"] = setting.AppSubURL + "/user/sign_up" @@ -1584,7 +1584,7 @@ func MustChangePassword(ctx *context.Context) { // MustChangePasswordPost response for updating a user's password after his/her // account was created by an admin func MustChangePasswordPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.MustChangePasswordForm) + form := web.GetForm(ctx).(*forms.MustChangePasswordForm) ctx.Data["Title"] = ctx.Tr("auth.must_change_password") ctx.Data["ChangePasscodeLink"] = setting.AppSubURL + "/user/settings/change_password" if ctx.HasError() { diff --git a/routers/user/auth_openid.go b/routers/user/auth_openid.go index 7db61dc09b..93a8861da7 100644 --- a/routers/user/auth_openid.go +++ b/routers/user/auth_openid.go @@ -13,7 +13,6 @@ import ( "code.gitea.io/gitea/modules/auth/openid" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/context" - auth "code.gitea.io/gitea/modules/forms" "code.gitea.io/gitea/modules/generate" "code.gitea.io/gitea/modules/hcaptcha" "code.gitea.io/gitea/modules/log" @@ -22,6 +21,7 @@ import ( "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/modules/web" "code.gitea.io/gitea/modules/web/middleware" + "code.gitea.io/gitea/services/forms" "code.gitea.io/gitea/services/mailer" ) @@ -92,7 +92,7 @@ func allowedOpenIDURI(uri string) (err error) { // SignInOpenIDPost response for openid sign in request func SignInOpenIDPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.SignInOpenIDForm) + form := web.GetForm(ctx).(*forms.SignInOpenIDForm) ctx.Data["Title"] = ctx.Tr("sign_in") ctx.Data["PageIsSignIn"] = true ctx.Data["PageIsLoginOpenID"] = true @@ -152,7 +152,7 @@ func signInOpenIDVerify(ctx *context.Context) { var id, err = openid.Verify(fullURL) if err != nil { - ctx.RenderWithErr(err.Error(), tplSignInOpenID, &auth.SignInOpenIDForm{ + ctx.RenderWithErr(err.Error(), tplSignInOpenID, &forms.SignInOpenIDForm{ Openid: id, }) return @@ -166,7 +166,7 @@ func signInOpenIDVerify(ctx *context.Context) { u, err := models.GetUserByOpenID(id) if err != nil { if !models.IsErrUserNotExist(err) { - ctx.RenderWithErr(err.Error(), tplSignInOpenID, &auth.SignInOpenIDForm{ + ctx.RenderWithErr(err.Error(), tplSignInOpenID, &forms.SignInOpenIDForm{ Openid: id, }) return @@ -185,14 +185,14 @@ func signInOpenIDVerify(ctx *context.Context) { parsedURL, err := url.Parse(fullURL) if err != nil { - ctx.RenderWithErr(err.Error(), tplSignInOpenID, &auth.SignInOpenIDForm{ + ctx.RenderWithErr(err.Error(), tplSignInOpenID, &forms.SignInOpenIDForm{ Openid: id, }) return } values, err := url.ParseQuery(parsedURL.RawQuery) if err != nil { - ctx.RenderWithErr(err.Error(), tplSignInOpenID, &auth.SignInOpenIDForm{ + ctx.RenderWithErr(err.Error(), tplSignInOpenID, &forms.SignInOpenIDForm{ Openid: id, }) return @@ -206,7 +206,7 @@ func signInOpenIDVerify(ctx *context.Context) { u, err = models.GetUserByEmail(email) if err != nil { if !models.IsErrUserNotExist(err) { - ctx.RenderWithErr(err.Error(), tplSignInOpenID, &auth.SignInOpenIDForm{ + ctx.RenderWithErr(err.Error(), tplSignInOpenID, &forms.SignInOpenIDForm{ Openid: id, }) return @@ -222,7 +222,7 @@ func signInOpenIDVerify(ctx *context.Context) { u, _ = models.GetUserByName(nickname) if err != nil { if !models.IsErrUserNotExist(err) { - ctx.RenderWithErr(err.Error(), tplSignInOpenID, &auth.SignInOpenIDForm{ + ctx.RenderWithErr(err.Error(), tplSignInOpenID, &forms.SignInOpenIDForm{ Openid: id, }) return @@ -279,7 +279,7 @@ func ConnectOpenID(ctx *context.Context) { // ConnectOpenIDPost handles submission of a form to connect an OpenID URI to an existing account func ConnectOpenIDPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.ConnectOpenIDForm) + form := web.GetForm(ctx).(*forms.ConnectOpenIDForm) oid, _ := ctx.Session.Get("openid_verified_uri").(string) if oid == "" { ctx.Redirect(setting.AppSubURL + "/user/login/openid") @@ -350,7 +350,7 @@ func RegisterOpenID(ctx *context.Context) { // RegisterOpenIDPost handles submission of a form to create a new user authenticated via an OpenID URI func RegisterOpenIDPost(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.SignUpOpenIDForm) + form := web.GetForm(ctx).(*forms.SignUpOpenIDForm) oid, _ := ctx.Session.Get("openid_verified_uri").(string) if oid == "" { ctx.Redirect(setting.AppSubURL + "/user/login/openid") diff --git a/routers/user/oauth.go b/routers/user/oauth.go index 4502c2bd39..c8c846c687 100644 --- a/routers/user/oauth.go +++ b/routers/user/oauth.go @@ -15,11 +15,11 @@ 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/timeutil" "code.gitea.io/gitea/modules/web" + "code.gitea.io/gitea/services/forms" "gitea.com/go-chi/binding" "github.com/dgrijalva/jwt-go" @@ -195,7 +195,7 @@ func newAccessTokenResponse(grant *models.OAuth2Grant, clientSecret string) (*Ac // AuthorizeOAuth manages authorize requests func AuthorizeOAuth(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.AuthorizationForm) + form := web.GetForm(ctx).(*forms.AuthorizationForm) errs := binding.Errors{} errs = form.Validate(ctx.Req, errs) if len(errs) > 0 { @@ -345,7 +345,7 @@ func AuthorizeOAuth(ctx *context.Context) { // GrantApplicationOAuth manages the post request submitted when a user grants access to an application func GrantApplicationOAuth(ctx *context.Context) { - form := web.GetForm(ctx).(*auth.GrantApplicationForm) + form := web.GetForm(ctx).(*forms.GrantApplicationForm) if ctx.Session.Get("client_id") != form.ClientID || ctx.Session.Get("state") != form.State || ctx.Session.Get("redirect_uri") != form.RedirectURI { ctx.Error(http.StatusBadRequest) @@ -391,7 +391,7 @@ func GrantApplicationOAuth(ctx *context.Context) { // AccessTokenOAuth manages all access token requests by the client func AccessTokenOAuth(ctx *context.Context) { - form := *web.GetForm(ctx).(*auth.AccessTokenForm) + form := *web.GetForm(ctx).(*forms.AccessTokenForm) if form.ClientID == "" { authHeader := ctx.Req.Header.Get("Authorization") authContent := strings.SplitN(authHeader, " ", 2) @@ -431,7 +431,7 @@ func AccessTokenOAuth(ctx *context.Context) { } } -func handleRefreshToken(ctx *context.Context, form auth.AccessTokenForm) { +func handleRefreshToken(ctx *context.Context, form forms.AccessTokenForm) { token, err := models.ParseOAuth2Token(form.RefreshToken) if err != nil { handleAccessTokenError(ctx, AccessTokenError{ @@ -467,7 +467,7 @@ func handleRefreshToken(ctx *context.Context, form auth.AccessTokenForm) { ctx.JSON(http.StatusOK, accessToken) } -func handleAuthorizationCode(ctx *context.Context, form auth.AccessTokenForm) { +func handleAuthorizationCode(ctx *context.Context, form forms.AccessTokenForm) { app, err := models.GetOAuth2ApplicationByClientID(form.ClientID) if err != nil { handleAccessTokenError(ctx, AccessTokenError{ 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) { |