Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ChpasswdCmd = &cobra.Command{ Use: "chpasswd", Short: "Force change password", Long: `Force change password`, Example: `sonar chpasswd -p <password>`, Run: func(cmd *cobra.Command, args []string) { if NewPassword == "" { cmd.Help() return } if _, err := os.Stat(dbcore.DatabaseFile); errors.Is(err, fs.ErrNotExist) { cmd.Println("Database file does not exist.") return } user, err := auth.GetFirstUser() if err != nil { cmd.Println("Error:", err) return } cmd.Println("Changing password for user:", user.Username) if err := auth.ForceResetPassword(user.Username, NewPassword); err != nil { cmd.Println("Error:", err) return } cmd.Println("Password changed successfully, new password:", NewPassword) if err := auth.DeleteAllSessions(); err != nil { cmd.Println("Unable to force logout of other devices:", err) return } cmd.Println("Please restart the server to apply the changes.") }, }
View Source
var Disable2FA = &cobra.Command{ Use: "disable-2fa", Short: "Force disable 2FA", Long: `Force disable 2FA`, Run: func(cmd *cobra.Command, args []string) { if err := auth.ForceDisableAllTwoFactor(); err != nil { cmd.Println("Error:", err) os.Exit(1) } cmd.Println("2FA has been disabled.") cmd.Println("Please restart the server to apply the changes.") }, }
View Source
var ( //Username string NewPassword string )
View Source
var PermitPasswordLoginCmd = &cobra.Command{ Use: "permit-login", Short: "Force permit password login", Long: `Force permit password login`, Run: func(cmd *cobra.Command, args []string) { dbcore.GetDBInstance() if err := kv.Set(settings.DisablePasswordLoginKey, false); err != nil { cmd.Println("Error:", err) os.Exit(1) } cmd.Println("Password login has been permitted.") cmd.Println("Please restart the server to apply the changes.") }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.