mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
CLI: Restore user accounts on demand #98
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
@@ -58,3 +58,24 @@ func (m *User) SetValuesFromCli(ctx *cli.Context) error {
|
||||
|
||||
return m.Validate()
|
||||
}
|
||||
|
||||
// RestoreFromCli restored the account from a CLI context.
|
||||
func (m *User) RestoreFromCli(ctx *cli.Context, newPassword string) (err error) {
|
||||
m.DeletedAt = nil
|
||||
|
||||
// Set values.
|
||||
if err = m.SetValuesFromCli(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Save values.
|
||||
if err = m.Save(); err != nil {
|
||||
return err
|
||||
} else if newPassword == "" {
|
||||
return nil
|
||||
} else if err = m.SetPassword(newPassword); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user