-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #257 from rusq/rod
ROD
- Loading branch information
Showing
45 changed files
with
664 additions
and
549 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package auth_ui | ||
|
||
import ( | ||
"net/url" | ||
"strings" | ||
) | ||
|
||
const ( | ||
LoginEmail = 0 | ||
LoginSSO = 1 | ||
) | ||
|
||
func Sanitize(workspace string) (string, error) { | ||
if !strings.Contains(workspace, ".slack.com") { | ||
return workspace, nil | ||
} | ||
if strings.HasPrefix(workspace, "https://") { | ||
uri, err := url.Parse(workspace) | ||
if err != nil { | ||
return "", err | ||
} | ||
workspace = uri.Host | ||
} | ||
// parse | ||
parts := strings.Split(workspace, ".") | ||
return parts[0], nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package auth_ui | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/charmbracelet/huh" | ||
) | ||
|
||
type Huh struct { | ||
theme huh.Theme | ||
} | ||
|
||
func (*Huh) RequestWorkspace(w io.Writer) (string, error) { | ||
var workspace string | ||
huh.NewInput(). | ||
Title("Enter Slack workspace name"). | ||
Value(&workspace). | ||
Validate(valRequired). | ||
Description("The workspace name is the part of the URL that comes before `.slack.com' in\nhttps://<workspace>.slack.com/. Both workspace name or URL are acceptable."). | ||
Run() | ||
return Sanitize(workspace) | ||
} | ||
|
||
func (*Huh) Stop() {} | ||
|
||
func (*Huh) RequestEmail(w io.Writer) (string, error) { | ||
var email string | ||
huh.NewInput().Title("Enter Slack login email"). | ||
Value(&email). | ||
Description("The email that you use to login to Slack."). | ||
Validate(valAND(valEmail, valRequired)). | ||
Run() | ||
return email, nil | ||
} | ||
|
||
func (*Huh) RequestPassword(w io.Writer, account string) (string, error) { | ||
var password string | ||
huh.NewInput().Title("Enter password for " + account). | ||
Value(&password). | ||
Password(true). | ||
Description("This is your Slack password, it will not be saved."). | ||
Validate(valRequired). | ||
Run() | ||
return password, nil | ||
} | ||
|
||
func (*Huh) RequestLoginType(w io.Writer) (int, error) { | ||
var loginType int | ||
err := huh.NewSelect[int]().Title("Select login type"). | ||
Options( | ||
huh.NewOption("Email", LoginEmail), | ||
huh.NewOption("Google", LoginSSO), | ||
huh.NewOption("Apple", LoginSSO), | ||
huh.NewOption("Login with Single-Sign-On (SSO)", LoginSSO), | ||
huh.NewOption("Other", LoginSSO), | ||
). | ||
Value(&loginType). | ||
Description("If you are not sure, select 'Other'."). | ||
Run() | ||
return loginType, err | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.