mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-02 09:58:29 +02:00
Login via oauth2 flow (#725)
Reviewed-on: https://gitea.com/gitea/tea/pulls/725 Co-authored-by: techknowlogick <techknowlogick@gitea.com> Co-committed-by: techknowlogick <techknowlogick@gitea.com>
This commit is contained in:

committed by
techknowlogick

parent
e82dd9e08d
commit
62dc1dde95
@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/auth"
|
||||
"code.gitea.io/tea/modules/task"
|
||||
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
@ -44,12 +45,22 @@ func CreateLogin() error {
|
||||
return err
|
||||
}
|
||||
|
||||
loginMethod, err := promptSelectV2("Login with: ", []string{"token", "ssh-key/certificate"})
|
||||
loginMethod, err := promptSelectV2("Login with: ", []string{"token", "ssh-key/certificate", "oauth"})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
switch loginMethod {
|
||||
case "oauth":
|
||||
promptYN := &survey.Confirm{
|
||||
Message: "Allow Insecure connections: ",
|
||||
Default: false,
|
||||
}
|
||||
if err = survey.AskOne(promptYN, &insecure); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return auth.OAuthLoginWithOptions(name, giteaURL, insecure)
|
||||
default: // token
|
||||
var hasToken bool
|
||||
promptYN := &survey.Confirm{
|
||||
@ -161,7 +172,6 @@ func CreateLogin() error {
|
||||
if err = survey.AskOne(promptYN, &versionCheck); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return task.CreateLogin(name, token, user, passwd, otp, scopes, sshKey, giteaURL, sshCertPrincipal, sshKeyFingerprint, insecure, sshAgent, versionCheck, helper)
|
||||
|
Reference in New Issue
Block a user