mirror of
https://github.com/photoprism/photoprism.git
synced 2025-10-25 09:50:33 +08:00
CLI: Restore user accounts on demand #98
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -3,13 +3,13 @@ package commands
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/photoprism/photoprism/pkg/rnd"
|
||||
|
||||
"github.com/manifoldco/promptui"
|
||||
"github.com/urfave/cli"
|
||||
|
||||
"github.com/photoprism/photoprism/internal/config"
|
||||
"github.com/photoprism/photoprism/internal/entity"
|
||||
"github.com/photoprism/photoprism/pkg/clean"
|
||||
"github.com/photoprism/photoprism/pkg/rnd"
|
||||
)
|
||||
|
||||
// UsersModCommand configures the command name, flags, and action.
|
||||
@@ -46,6 +46,21 @@ func usersModAction(ctx *cli.Context) error {
|
||||
return fmt.Errorf("user %s not found", clean.LogQuote(id))
|
||||
}
|
||||
|
||||
// Check if account exists but is deleted.
|
||||
if m.Deleted() {
|
||||
prompt := promptui.Prompt{
|
||||
Label: fmt.Sprintf("Restore user %s?", m.String()),
|
||||
IsConfirm: true,
|
||||
}
|
||||
|
||||
if _, err := prompt.Run(); err != nil {
|
||||
return fmt.Errorf("user already exists")
|
||||
}
|
||||
|
||||
m.DeletedAt = nil
|
||||
log.Infof("user %s will be restored", m.String())
|
||||
}
|
||||
|
||||
// Set values.
|
||||
if err := m.SetValuesFromCli(ctx); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user