Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 790c82f

Browse files
authoredSep 26, 2021
Merge branch 'main' into extend-skip2fa-to-pam-smtp
2 parents 328dcb9 + 74542ad commit 790c82f

File tree

259 files changed

+2885
-2428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

259 files changed

+2885
-2428
lines changed
 

‎.golangci.yml

-1
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,3 @@ issues:
111111
linters:
112112
- staticcheck
113113
text: "svc.IsAnInteractiveSession is deprecated: Use IsWindowsService instead."
114-

‎cmd/admin.go

+12-9
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,16 @@ import (
1414
"text/tabwriter"
1515

1616
"code.gitea.io/gitea/models"
17+
"code.gitea.io/gitea/models/db"
18+
"code.gitea.io/gitea/models/login"
1719
"code.gitea.io/gitea/modules/git"
1820
"code.gitea.io/gitea/modules/graceful"
1921
"code.gitea.io/gitea/modules/log"
2022
pwd "code.gitea.io/gitea/modules/password"
2123
repo_module "code.gitea.io/gitea/modules/repository"
2224
"code.gitea.io/gitea/modules/setting"
2325
"code.gitea.io/gitea/modules/storage"
26+
auth_service "code.gitea.io/gitea/services/auth"
2427
"code.gitea.io/gitea/services/auth/source/oauth2"
2528

2629
"github.com/urfave/cli"
@@ -529,7 +532,7 @@ func runRepoSyncReleases(_ *cli.Context) error {
529532
log.Trace("Synchronizing repository releases (this may take a while)")
530533
for page := 1; ; page++ {
531534
repos, count, err := models.SearchRepositoryByName(&models.SearchRepoOptions{
532-
ListOptions: models.ListOptions{
535+
ListOptions: db.ListOptions{
533536
PageSize: models.RepositoryListDefaultPageSize,
534537
Page: page,
535538
},
@@ -629,8 +632,8 @@ func runAddOauth(c *cli.Context) error {
629632
return err
630633
}
631634

632-
return models.CreateLoginSource(&models.LoginSource{
633-
Type: models.LoginOAuth2,
635+
return login.CreateSource(&login.Source{
636+
Type: login.OAuth2,
634637
Name: c.String("name"),
635638
IsActive: true,
636639
Cfg: parseOAuth2Config(c),
@@ -646,7 +649,7 @@ func runUpdateOauth(c *cli.Context) error {
646649
return err
647650
}
648651

649-
source, err := models.GetLoginSourceByID(c.Int64("id"))
652+
source, err := login.GetSourceByID(c.Int64("id"))
650653
if err != nil {
651654
return err
652655
}
@@ -705,15 +708,15 @@ func runUpdateOauth(c *cli.Context) error {
705708
oAuth2Config.CustomURLMapping = customURLMapping
706709
source.Cfg = oAuth2Config
707710

708-
return models.UpdateSource(source)
711+
return login.UpdateSource(source)
709712
}
710713

711714
func runListAuth(c *cli.Context) error {
712715
if err := initDB(); err != nil {
713716
return err
714717
}
715718

716-
loginSources, err := models.LoginSources()
719+
loginSources, err := login.Sources()
717720

718721
if err != nil {
719722
return err
@@ -733,7 +736,7 @@ func runListAuth(c *cli.Context) error {
733736
w := tabwriter.NewWriter(os.Stdout, c.Int("min-width"), c.Int("tab-width"), c.Int("padding"), padChar, flags)
734737
fmt.Fprintf(w, "ID\tName\tType\tEnabled\n")
735738
for _, source := range loginSources {
736-
fmt.Fprintf(w, "%d\t%s\t%s\t%t\n", source.ID, source.Name, models.LoginNames[source.Type], source.IsActive)
739+
fmt.Fprintf(w, "%d\t%s\t%s\t%t\n", source.ID, source.Name, source.Type.String(), source.IsActive)
737740
}
738741
w.Flush()
739742

@@ -749,10 +752,10 @@ func runDeleteAuth(c *cli.Context) error {
749752
return err
750753
}
751754

752-
source, err := models.GetLoginSourceByID(c.Int64("id"))
755+
source, err := login.GetSourceByID(c.Int64("id"))
753756
if err != nil {
754757
return err
755758
}
756759

757-
return models.DeleteSource(source)
760+
return auth_service.DeleteLoginSource(source)
758761
}

0 commit comments

Comments
 (0)
Please sign in to comment.