/
mfa_option.go
49 lines (41 loc) · 990 Bytes
/
mfa_option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package auth
import (
"strings"
"text/template"
)
var (
confirmInstruction = "Please wait for your admin to confirm."
confirmQuestion = "Do you want to continue [Y/n]? : "
)
const (
actionAccepted = "Accepted"
actionFailed = "Failed"
actionPartialAccepted = "Partial accepted"
)
func CreateSelectOptionsQuestion(options []string) string {
opts := make([]mfaOption, 0, len(options))
for i := range options {
opts = append(opts, mfaOption{
Index: i + 1,
Value: strings.ToUpper(options[i]),
})
}
var out strings.Builder
_ = mfaSelectTmpl.Execute(&out, opts)
return out.String()
}
var (
mfaSelectTmpl = template.Must(template.New("mfaOptions").Parse(mfaOptions))
mfaSelectInstruction = "Please Select MFA Option"
)
type mfaOption struct {
Index int
Value string
}
var mfaOptions = `
{{ range . }}{{ .Index }}. {{.Value}}
{{end}}Option> `
var (
mfaOptionInstruction = "Please Enter MFA Code."
mfaOptionQuestion = "[%s Code]: "
)