feat(auth): enhance login flow with notifications and path normalization
Some checks failed
CI / Test (1.22) (push) Failing after -30m33s
CI / Test (1.23) (push) Failing after -30m32s
CI / Lint (push) Failing after -30m39s
CI / Build (push) Failing after -30m35s

- add success notification on successful login
- show error notification with detailed message on login failure
- normalize API paths to prevent double slashes and trailing slashes
- redirect to login page only if not on login request or page
This commit is contained in:
2026-03-05 01:03:50 +02:00
parent 1490e0b596
commit 271a0603b8
10 changed files with 230 additions and 29 deletions

View File

@@ -25,6 +25,10 @@ var rootCmd = &cobra.Command{
Short: "WhatsHooked CLI - Manage WhatsApp webhooks",
Long: `A command-line interface for managing WhatsHooked server, hooks, and WhatsApp accounts.`,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if shouldSkipConfigLoad(cmd) {
return
}
var err error
cliConfig, err = LoadCLIConfig(cfgFile, serverURL)
if err != nil {
@@ -44,4 +48,14 @@ func init() {
rootCmd.AddCommand(accountsCmd)
rootCmd.AddCommand(sendCmd)
rootCmd.AddCommand(usersCmd)
rootCmd.AddCommand(passwordHashCmd)
}
func shouldSkipConfigLoad(cmd *cobra.Command) bool {
for c := cmd; c != nil; c = c.Parent() {
if c.Annotations != nil && c.Annotations["skip-config-load"] == "true" {
return true
}
}
return false
}