Skip to content

Commit

Permalink
only shortcircuit the login command if the RAILWAY_API_TOKEN is found
Browse files Browse the repository at this point in the history
  • Loading branch information
coffee-cup committed Oct 22, 2024
1 parent 06faa5a commit 5a480e9
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/commands/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,22 @@ pub async fn command(args: Args, _json: bool) -> Result<()> {
interact_or!("Cannot login in non-interactive mode");

let mut configs = Configs::new()?;
if let Ok(client) = GQLClient::new_authorized(&configs) {
match get_user(&client, &configs).await {
Ok(user) => {
println!("{} found", "RAILWAY_TOKEN".bold());
print_user(user);
return Ok(());
}
Err(_e) => {
println!("Found invalid {}", "RAILWAY_TOKEN".bold());
return Err(RailwayError::InvalidRailwayToken.into());

if Configs::get_railway_api_token().is_some() {
if let Ok(client) = GQLClient::new_authorized(&configs) {
match get_user(&client, &configs).await {
Ok(user) => {
println!("{} found", "RAILWAY_TOKEN".bold());
print_user(user);
return Ok(());
}
Err(_e) => {
println!("Found invalid {}", "RAILWAY_TOKEN".bold());
return Err(RailwayError::InvalidRailwayToken.into());
}
}
}
}

if args.browserless {
return browserless_login().await;
}
Expand Down

0 comments on commit 5a480e9

Please sign in to comment.