diff options
author | 6543 <6543@obermui.de> | 2020-09-11 00:29:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-10 23:29:19 +0100 |
commit | fd60ebfe14927657ff5cfa4e75f975eaadae65f1 (patch) | |
tree | 38c3d70146920a13c228fed91bc1a55c9be72436 /modules/auth | |
parent | daefdd1385d12bf0c8321f291dbb6ab242b41c99 (diff) | |
download | gitea-fd60ebfe14927657ff5cfa4e75f975eaadae65f1.tar.gz gitea-fd60ebfe14927657ff5cfa4e75f975eaadae65f1.zip |
[API] Migration: Change ServiceType String (#12672)
* use different structs for MigrateRepoOptions on UI and API
* Fix TokenAuth and rename UID to an understandable Name
* fix swagger doc
* simplify & mk redable
* R E F A C T O R:
migration has now internal 3 structs to store its options:
* the Options for WebUI: modules/auth/repo_form.go
* the Options for API: modules/structs/repo.go
* the option struct with after validation for internal prossessing: modules/migrations/base/options.go
* Copyright Header
* Deprecate UID - add RepoOwner
* adopt repo.go -> migrate.go
* add comment about each struct purpose
* lint
Diffstat (limited to 'modules/auth')
-rw-r--r-- | modules/auth/repo_form.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index b3fead7da9..3ad57085b0 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -53,6 +53,7 @@ func (f *CreateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) bin } // MigrateRepoForm form for migrating repository +// this is used to interact with web ui type MigrateRepoForm struct { // required: true CloneAddr string `json:"clone_addr" binding:"Required"` @@ -84,9 +85,8 @@ func (f *MigrateRepoForm) Validate(ctx *macaron.Context, errs binding.Errors) bi // and returns composed URL with needed username and password. // It also checks if given user has permission when remote address // is actually a local path. -func (f MigrateRepoForm) ParseRemoteAddr(user *models.User) (string, error) { - remoteAddr := strings.TrimSpace(f.CloneAddr) - +func ParseRemoteAddr(remoteAddr, authUsername, authPassword string, user *models.User) (string, error) { + remoteAddr = strings.TrimSpace(remoteAddr) // Remote address can be HTTP/HTTPS/Git URL or local path. if strings.HasPrefix(remoteAddr, "http://") || strings.HasPrefix(remoteAddr, "https://") || @@ -95,8 +95,8 @@ func (f MigrateRepoForm) ParseRemoteAddr(user *models.User) (string, error) { if err != nil { return "", models.ErrInvalidCloneAddr{IsURLError: true} } - if len(f.AuthUsername)+len(f.AuthPassword) > 0 { - u.User = url.UserPassword(f.AuthUsername, f.AuthPassword) + if len(authUsername)+len(authPassword) > 0 { + u.User = url.UserPassword(authUsername, authPassword) } remoteAddr = u.String() } else if !user.CanImportLocal() { |