Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
willvedd authored and sergiught committed Dec 9, 2022
1 parent 0001874 commit abaf51e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
10 changes: 6 additions & 4 deletions internal/auth/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ func (t *TokenRetriever) Delete(tenant string) error {
// The request is used the default client_id and endpoint for device authentication.
func (t *TokenRetriever) Refresh(ctx context.Context, tenant string) (TokenResponse, error) {
// get stored refresh token:
refreshToken, err := t.Secrets.Get(SecretsNamespace, tenant)
if err != nil {
return TokenResponse{}, fmt.Errorf("cannot get the stored refresh token: %w", err)
}
// refreshToken, err := t.Secrets.Get(SecretsNamespace, tenant)
// if err != nil {
// return TokenResponse{}, fmt.Errorf("cannot get the stored refresh token: %w", err)
// }

refreshToken := "fadsfasdf"
if refreshToken == "" {
return TokenResponse{}, errors.New("cannot use the stored refresh token: the token is empty")
}
Expand Down
10 changes: 5 additions & 5 deletions internal/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ func (c *cli) prepareTenant(ctx context.Context) (Tenant, error) {
}

if err := t.regenerateAccessToken(ctx, c); err != nil {
// Ask and guide the user through the login process.
if t.authenticatedWithDeviceCodeFlow() {
c.renderer.Warnf("Failed to renew access token. Please sign in to re-authenticate the CLI.")
return RunLoginAsUser(ctx, c)
if t.authenticatedWithClientCredentials() {
return t, fmt.Errorf("Failed to renew access token. This may occur if the designated application has been deleted or client secret has been rotated. Please re-authenticate by running `auth0 login --as-machine`")
}

return t, fmt.Errorf("Failed to renew access token. This may occur if the designated application has been deleted or client secret has been rotated. Please re-authenticate by running `auth0 login --as-machine`")
c.renderer.Warnf("Failed to renew access token. Please sign in to re-authenticate the CLI.")
return RunLoginAsUser(ctx, c)

}

if err := c.addTenant(t); err != nil {
Expand Down
5 changes: 3 additions & 2 deletions internal/cli/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ auth0 login --domain <tenant-domain> --client-id <client-id> --client-secret <cl
return err
}
} else {
cli.renderer.Output(fmt.Sprintf(
welcomeMessage := fmt.Sprintf(
"%s\n\n%s\n\n",
"✪ Welcome to the Auth0 CLI 🎊",
"If you don't have an account, please create one here: https://auth0.com/signup.",
))
)
cli.renderer.Output(welcomeMessage)
if _, err := RunLoginAsUser(ctx, cli); err != nil {
return err
}
Expand Down

0 comments on commit abaf51e

Please sign in to comment.