promptAuthMode prompts the user to select authentication mode
()
| 122 | |
| 123 | // promptAuthMode prompts the user to select authentication mode |
| 124 | func promptAuthMode() (string, error) { |
| 125 | printStepHeader(2, 8, "Choose Authentication Mode") |
| 126 | |
| 127 | // Check Touch ID availability (macOS only) |
| 128 | touchIDAvailable := runtime.GOOS == "darwin" |
| 129 | |
| 130 | if touchIDAvailable { |
| 131 | fmt.Println("✓ Your Mac supports Touch ID!") |
| 132 | fmt.Println() |
| 133 | } |
| 134 | |
| 135 | fmt.Println("Available modes:") |
| 136 | fmt.Println(" 1) Touch ID (recommended) - Use your fingerprint") |
| 137 | fmt.Println(" 2) OTP - Use password + authenticator app") |
| 138 | fmt.Println() |
| 139 | |
| 140 | for { |
| 141 | choice, err := otp.PromptInput("Choose authentication mode [1]: ") |
| 142 | if err != nil { |
| 143 | return "", err |
| 144 | } |
| 145 | |
| 146 | // Default to Touch ID |
| 147 | if choice == "" { |
| 148 | choice = "1" |
| 149 | } |
| 150 | |
| 151 | switch choice { |
| 152 | case "1", "touchid", "TouchID": |
| 153 | if !touchIDAvailable { |
| 154 | fmt.Println("❌ Touch ID is only available on macOS") |
| 155 | continue |
| 156 | } |
| 157 | return "touchid", nil |
| 158 | case "2", "otp", "OTP": |
| 159 | return "otp", nil |
| 160 | default: |
| 161 | fmt.Println("Invalid choice. Please enter 1 or 2.") |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | // printStepHeader prints a step header |
| 167 | func printStepHeader(step, total int, title string) { |
no test coverage detected