@@ -14,13 +14,16 @@ import (
14
14
"text/tabwriter"
15
15
16
16
"code.gitea.io/gitea/models"
17
+ "code.gitea.io/gitea/models/db"
18
+ "code.gitea.io/gitea/models/login"
17
19
"code.gitea.io/gitea/modules/git"
18
20
"code.gitea.io/gitea/modules/graceful"
19
21
"code.gitea.io/gitea/modules/log"
20
22
pwd "code.gitea.io/gitea/modules/password"
21
23
repo_module "code.gitea.io/gitea/modules/repository"
22
24
"code.gitea.io/gitea/modules/setting"
23
25
"code.gitea.io/gitea/modules/storage"
26
+ auth_service "code.gitea.io/gitea/services/auth"
24
27
"code.gitea.io/gitea/services/auth/source/oauth2"
25
28
26
29
"github.com/urfave/cli"
@@ -529,7 +532,7 @@ func runRepoSyncReleases(_ *cli.Context) error {
529
532
log .Trace ("Synchronizing repository releases (this may take a while)" )
530
533
for page := 1 ; ; page ++ {
531
534
repos , count , err := models .SearchRepositoryByName (& models.SearchRepoOptions {
532
- ListOptions : models .ListOptions {
535
+ ListOptions : db .ListOptions {
533
536
PageSize : models .RepositoryListDefaultPageSize ,
534
537
Page : page ,
535
538
},
@@ -629,8 +632,8 @@ func runAddOauth(c *cli.Context) error {
629
632
return err
630
633
}
631
634
632
- return models . CreateLoginSource ( & models. LoginSource {
633
- Type : models . LoginOAuth2 ,
635
+ return login . CreateSource ( & login. Source {
636
+ Type : login . OAuth2 ,
634
637
Name : c .String ("name" ),
635
638
IsActive : true ,
636
639
Cfg : parseOAuth2Config (c ),
@@ -646,7 +649,7 @@ func runUpdateOauth(c *cli.Context) error {
646
649
return err
647
650
}
648
651
649
- source , err := models . GetLoginSourceByID (c .Int64 ("id" ))
652
+ source , err := login . GetSourceByID (c .Int64 ("id" ))
650
653
if err != nil {
651
654
return err
652
655
}
@@ -705,15 +708,15 @@ func runUpdateOauth(c *cli.Context) error {
705
708
oAuth2Config .CustomURLMapping = customURLMapping
706
709
source .Cfg = oAuth2Config
707
710
708
- return models .UpdateSource (source )
711
+ return login .UpdateSource (source )
709
712
}
710
713
711
714
func runListAuth (c * cli.Context ) error {
712
715
if err := initDB (); err != nil {
713
716
return err
714
717
}
715
718
716
- loginSources , err := models . LoginSources ()
719
+ loginSources , err := login . Sources ()
717
720
718
721
if err != nil {
719
722
return err
@@ -733,7 +736,7 @@ func runListAuth(c *cli.Context) error {
733
736
w := tabwriter .NewWriter (os .Stdout , c .Int ("min-width" ), c .Int ("tab-width" ), c .Int ("padding" ), padChar , flags )
734
737
fmt .Fprintf (w , "ID\t Name\t Type\t Enabled\n " )
735
738
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 )
737
740
}
738
741
w .Flush ()
739
742
@@ -749,10 +752,10 @@ func runDeleteAuth(c *cli.Context) error {
749
752
return err
750
753
}
751
754
752
- source , err := models . GetLoginSourceByID (c .Int64 ("id" ))
755
+ source , err := login . GetSourceByID (c .Int64 ("id" ))
753
756
if err != nil {
754
757
return err
755
758
}
756
759
757
- return models . DeleteSource (source )
760
+ return auth_service . DeleteLoginSource (source )
758
761
}
0 commit comments