Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-29 05:06:11 +01:00

feat: add synchronize users cli command

This commit is contained in:
Emmanuel Averty 2024-04-03 23:25:02 +02:00
parent ef9a0c8d3d
commit bd4ae5cda3
2 changed files with 23 additions and 0 deletions

View file

@ -61,6 +61,7 @@ var (
microcmdAuthUpdateSMTP,
microcmdAuthList,
microcmdAuthDelete,
microcmdAuthSyncUsers,
},
}

View file

@ -54,6 +54,17 @@ var (
},
},
}
microcmdAuthSyncUsers = &cli.Command{
Name: "sync-users",
Usage: "Synchronize external users",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "update-existing",
Usage: "Set to true to update existing users",
},
},
Action: runSyncUsers,
}
)
func runListAuth(c *cli.Context) error {
@ -109,3 +120,14 @@ func runDeleteAuth(c *cli.Context) error {
return auth_service.DeleteSource(ctx, source)
}
func runSyncUsers(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
if err := initDB(ctx); err != nil {
return err
}
return auth_service.SyncExternalUsers(ctx, c.Bool("update-existing"))
}