func (verification *Verification) Run() error { utils.PrintMessage("Sending approval request to your device... ") request, err := verification.SendOneTouchRequest() if err != nil { utils.PrintMessage(err.Error()) return ErrInvalidVerification } utils.PrintMessage(ansi.Color("[sent]\n", "green+h")) status, err := verification.api.WaitForApprovalRequest(request.UUID, ApprovalTimeout, url.Values{}) if err != nil { utils.PrintMessage(err.Error()) return ErrInvalidVerification } if status == authy.OneTouchStatusApproved { runShell() return nil } if status == authy.OneTouchStatusExpired && utils.IsInteractiveConnection() { utils.PrintMessage("You didn't confirm the request. ") code := verification.askTOTPCode() if verification.verifyCode(code) { runShell() return nil } } return ErrInvalidVerification }
func (verification *Verification) sendTOTPCode() { _, err := verification.api.RequestSMS(verification.authyID, url.Values{}) if err != nil { return } // TODO: check if the SMS request was ignored utils.PrintMessage("A text-message was sent to your phone.\n") }
func runShell() { config, err := LoadConfig() // Check if the config could be loaded to get preferred user shell. if err == nil { utils.PrintMessage("You've been logged in successfully.\n") if len(config.ShellPath) != 0 { if len(config.ShellArgs) != 0 { utils.RunShellFromPathWithArgs( config.ShellPath, config.ShellArgs) } else { utils.RunShellFromPath(config.ShellPath) } } else { utils.RunShell() } } else { utils.RunShell() } }