add send user password reset email command line utility

This commit is contained in:
MaysWind
2023-08-27 21:36:39 +08:00
parent de7b137257
commit 4ac751f492
2 changed files with 66 additions and 0 deletions
+33
View File
@@ -86,6 +86,19 @@ var UserData = &cli.Command{
},
},
},
{
Name: "send-password-reset-mail",
Usage: "Send password reset mail",
Action: sendPasswordResetMail,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "username",
Aliases: []string{"n"},
Required: true,
Usage: "Specific user name",
},
},
},
{
Name: "user-enable",
Usage: "Enable specified user",
@@ -265,6 +278,26 @@ func modifyUserPassword(c *cli.Context) error {
return nil
}
func sendPasswordResetMail(c *cli.Context) error {
_, err := initializeSystem(c)
if err != nil {
return err
}
username := c.String("username")
err = clis.UserData.SendPasswordResetMail(c, username)
if err != nil {
log.BootErrorf("[user_data.sendPasswordResetMail] error occurs when sending password reset email")
return err
}
log.BootInfof("[user_data.sendPasswordResetMail] a password reset email for user \"%s\" has been sent", username)
return nil
}
func enableUser(c *cli.Context) error {
_, err := initializeSystem(c)