mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 20:27:43 +00:00
feat: interactive login
This commit is contained in:
@@ -98,13 +98,22 @@ var loginCmd = &cobra.Command{
|
|||||||
util.HandleError(err, "Unable to parse domain url")
|
util.HandleError(err, "Unable to parse domain url")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var userCredentialsToBeStored models.UserCredentials
|
||||||
|
|
||||||
|
interactiveLogin := false
|
||||||
|
if cmd.Flags().Changed("interactive") {
|
||||||
|
interactiveLogin = true
|
||||||
|
cliDefaultLogin(&userCredentialsToBeStored)
|
||||||
|
}
|
||||||
|
|
||||||
//call browser login function
|
//call browser login function
|
||||||
fmt.Printf("\nLogging in via browser... Hit '%s' to cancel\n", QUIT_BROWSER_LOGIN)
|
if !interactiveLogin {
|
||||||
userCredentialsToBeStored, err := browserCliLogin()
|
fmt.Printf("\nLogging in via browser... Hit '%s' to cancel\n", QUIT_BROWSER_LOGIN)
|
||||||
if err != nil {
|
userCredentialsToBeStored, err = browserCliLogin()
|
||||||
//default to cli login on error
|
if err != nil {
|
||||||
cliDefaultLogin(&userCredentialsToBeStored)
|
//default to cli login on error
|
||||||
|
cliDefaultLogin(&userCredentialsToBeStored)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = util.StoreUserCredsInKeyRing(&userCredentialsToBeStored)
|
err = util.StoreUserCredsInKeyRing(&userCredentialsToBeStored)
|
||||||
@@ -303,6 +312,7 @@ func cliDefaultLogin(userCredentialsToBeStored *models.UserCredentials) {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(loginCmd)
|
rootCmd.AddCommand(loginCmd)
|
||||||
|
loginCmd.Flags().BoolP("interactive", "i", false, "login via the command line")
|
||||||
}
|
}
|
||||||
|
|
||||||
func DomainOverridePrompt() (bool, error) {
|
func DomainOverridePrompt() (bool, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user