Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Jun 20, 2023
1 parent b829437 commit fd91013
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/cli/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,25 @@ pub struct Args {

pub async fn execute(args: Args) -> anyhow::Result<()> {
let storage = default_authentication_storage();



if let Some(conda_token) = args.conda_token {
let auth = Authentication::CondaToken(conda_token);
storage.store(&args.host, &auth)?;
return Ok(())
}
else if let Some(username) = args.username {
Ok(())
} else if let Some(username) = args.username {
if args.password.is_none() {
anyhow::bail!("Password must be provided when using basic authentication");
}

let password = args.password.unwrap();
let auth = Authentication::BasicHTTP{username, password};
let auth = Authentication::BasicHTTP { username, password };
storage.store(&args.host, &auth)?;
return Ok(())
}
else if let Some(token) = args.token {
Ok(())
} else if let Some(token) = args.token {
let auth = Authentication::BearerToken(token);
storage.store(&args.host, &auth)?;
return Ok(())
}
else {
Ok(())
} else {
anyhow::bail!("No authentication method provided");
}
}

0 comments on commit fd91013

Please sign in to comment.