package bio.terra.cli.command.auth;

import bio.terra.cli.businessobject.Context;
import bio.terra.cli.command.shared.BaseCommand;
import picocli.CommandLine.Command;

/** This class corresponds to the third-level "terra auth login" command. */
@Command(
    name = "login",
    description = "Authorize the CLI to access Terra APIs and data with user credentials.")
public class Login extends BaseCommand {

  /** Login the user and print out a success message. */
  @Override
  protected void execute() {
    // the base class will always login the user unless the {@link CommandSetup#doLogin}
    // method is overridden
    OUT.println("Login successful: " + Context.requireUser().getEmail());
  }
}

@@ -75,16 +75,58 @@
 ontext;%0A
+import bio.terra.cli.businessobject.User;%0A
 import b
@@ -166,16 +166,16 @@
 ommand;%0A
-
 import p
@@ -552,191 +552,396 @@
   //
+ if
  the 
-base class will always login the user unless the %7B@link CommandSetup#doLogin%7D%0A    // method is overridden%0A    OUT.println(%22Login successful: %22 + Context.requireUser().getEmail())
+user is already logged in, log them out first%0A    if (Context.getUser().isPresent()) %7B%0A      Context.requireUser().logout();%0A    %7D%0A%0A    User.login();%0A    OUT.println(%22Login successful: %22 + Context.requireUser().getEmail());%0A  %7D%0A%0A  /** Suppress the login by the super class, so that we can logout the user first, if needed. */%0A  protected boolean requiresLogin() %7B%0A    return false
 ;%0A  

Make auth login trigger a new login always.