Skip to content

Commit e4b1ca8

Browse files
authored
only shortcircuit the login command if the RAILWAY_API_TOKEN is found (#569)
1 parent 06faa5a commit e4b1ca8

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/commands/login.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,22 @@ pub async fn command(args: Args, _json: bool) -> Result<()> {
3030
interact_or!("Cannot login in non-interactive mode");
3131

3232
let mut configs = Configs::new()?;
33-
if let Ok(client) = GQLClient::new_authorized(&configs) {
34-
match get_user(&client, &configs).await {
35-
Ok(user) => {
36-
println!("{} found", "RAILWAY_TOKEN".bold());
37-
print_user(user);
38-
return Ok(());
39-
}
40-
Err(_e) => {
41-
println!("Found invalid {}", "RAILWAY_TOKEN".bold());
42-
return Err(RailwayError::InvalidRailwayToken.into());
33+
34+
if Configs::get_railway_api_token().is_some() {
35+
if let Ok(client) = GQLClient::new_authorized(&configs) {
36+
match get_user(&client, &configs).await {
37+
Ok(user) => {
38+
println!("{} found", "RAILWAY_TOKEN".bold());
39+
print_user(user);
40+
return Ok(());
41+
}
42+
Err(_e) => {
43+
println!("Found invalid {}", "RAILWAY_TOKEN".bold());
44+
return Err(RailwayError::InvalidRailwayToken.into());
45+
}
4346
}
4447
}
4548
}
46-
4749
if args.browserless {
4850
return browserless_login().await;
4951
}

0 commit comments

Comments
 (0)