MCPcopy
hub / github.com/tinyauthapp/tinyauth / ParseUser

Function ParseUser

internal/utils/user_utils.go:65–94  ·  view source on GitHub ↗
(userStr string)

Source from the content-addressed store, hash-verified

63}
64
65func ParseUser(userStr string) (config.User, error) {
66 if strings.Contains(userStr, "$$") {
67 userStr = strings.ReplaceAll(userStr, "$$", "$")
68 }
69
70 parts := strings.SplitN(userStr, ":", 4)
71
72 if len(parts) < 2 || len(parts) > 3 {
73 return config.User{}, errors.New("invalid user format")
74 }
75
76 for i, part := range parts {
77 trimmed := strings.TrimSpace(part)
78 if trimmed == "" {
79 return config.User{}, errors.New("invalid user format")
80 }
81 parts[i] = trimmed
82 }
83
84 user := config.User{
85 Username: parts[0],
86 Password: parts[1],
87 }
88
89 if len(parts) == 3 {
90 user.TotpSecret = parts[2]
91 }
92
93 return user, nil
94}
95
96func CompileUserEmail(username string, domain string) string {
97 _, err := mail.ParseAddress(username)

Callers 4

TestParseUserFunction · 0.92
generateTotpCmdFunction · 0.92
verifyUserCmdFunction · 0.92
ParseUsersFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestParseUserFunction · 0.74