Skip to content

Commit

Permalink
finish migrating 2fa subcommand code
Browse files Browse the repository at this point in the history
  • Loading branch information
ctreatma committed Jan 24, 2024
1 parent ce17551 commit a7d9ba9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions internal/twofa/disable2fa.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ func (c *Client) Disable() *cobra.Command {

cmd.SilenceUsage = true
if sms {
_, err := c.TwoFAService.DisableTfaSms(context.Background()).Execute()
_, err := c.TwoFAService.DisableTfaSms(context.Background()).XOtpToken(token).Execute()
if err != nil {
return fmt.Errorf("Could not disable Two-Factor Authentication via SMS: %w", err)
}
} else if app {
_, err := c.TwoFAService.DisableTfaApp(context.Background()).Execute()
_, err := c.TwoFAService.DisableTfaApp(context.Background()).XOtpToken(token).Execute()
if err != nil {
return fmt.Errorf("Could not disable Two-Factor Authentication via App: %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions internal/twofa/enable2fa.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ func (c *Client) Enable() *cobra.Command {

cmd.SilenceUsage = true
if sms {
_, err := c.TwoFAService.EnableTfaSms(context.Background()).Execute()
_, err := c.TwoFAService.EnableTfaSms(context.Background()).XOtpToken(token).Execute()
if err != nil {
return fmt.Errorf("Could not enable Two-Factor Authentication: %w", err)
}
} else if app {
_, err := c.TwoFAService.EnableTfaApp(context.Background()).Execute()
_, err := c.TwoFAService.EnableTfaApp(context.Background()).XOtpToken(token).Execute()
if err != nil {
return fmt.Errorf("Could not enable Two-Factor Authentication: %w", err)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/twofa/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ func (c *Client) Receive() *cobra.Command {
return nil
}

otpURI, _, err := c.TwoFAService.SeedApp()
resp, _, err := c.OtpService.SeedApp(context.Background()).Execute()
if err != nil {
return fmt.Errorf("Could not get the OTP Seed URI: %w", err)
}

data := make([][]string, 1)

data[0] = []string{otpURI}
data[0] = []string{resp.GetOtpUri()}
header := []string{"OTP URI"}
return c.Out.Output(otpURI, header, &data)
return c.Out.Output(resp, header, &data)
},
}

Expand Down
8 changes: 4 additions & 4 deletions internal/twofa/twofa.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ package twofa
import (
"github.com/equinix/metal-cli/internal/outputs"

metal "github.com/equinix-labs/metal-go/metal/v1"
"github.com/equinix/equinix-sdk-go/services/metalv1"
"github.com/spf13/cobra"
)

type Client struct {
Servicer Servicer
TwoFAService *metal.TwoFactorAuthApiService
OtpService *metal.OTPsApiService
TwoFAService *metalv1.TwoFactorAuthApiService
OtpService *metalv1.OTPsApiService
Out outputs.Outputer
}

Expand Down Expand Up @@ -61,7 +61,7 @@ func (c *Client) NewCommand() *cobra.Command {
}

type Servicer interface {
MetalAPI(*cobra.Command) *metal.APIClient
MetalAPI(*cobra.Command) *metalv1.APIClient
Filters() map[string]string
Includes(defaultIncludes []string) (incl []string)
Excludes(defaultExcludes []string) (excl []string)
Expand Down

0 comments on commit a7d9ba9

Please sign in to comment.