feat(auth): enhance login flow with notifications and path normalization
- 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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user