Skip to content

Commit 02fe82e

Browse files
committed
clippy
1 parent 3cd8474 commit 02fe82e

File tree

3 files changed

+13
-17
lines changed

3 files changed

+13
-17
lines changed

crates/chat-cli/src/auth/portal.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ pub async fn start_unified_auth(db: &mut Database) -> Result<PortalResult, AuthE
8383
let listener = bind_allowed_port(CALLBACK_PORTS).await?;
8484
let port = listener.local_addr()?.port();
8585

86-
let redirect_base = format!("http://localhost:{}", port);
86+
let redirect_base = format!("http://localhost:{port}");
8787
info!(%port, %redirect_base, "Unified auth portal listening for callback");
8888

8989
let auth_url = build_auth_url(&redirect_base, &state, &challenge);
9090

9191
crate::util::open::open_url_async(&auth_url)
9292
.await
93-
.map_err(|e| AuthError::OAuthCustomError(format!("Failed to open browser: {}", e)))?;
93+
.map_err(|e| AuthError::OAuthCustomError(format!("Failed to open browser: {e}")))?;
9494

9595
let callback = wait_for_auth_callback(listener, state.clone()).await?;
9696

@@ -121,20 +121,17 @@ fn format_user_friendly_error(error_code: &str, description: Option<&str>, provi
121121

122122
match error_code {
123123
"access_denied" => {
124-
format!(
125-
"{} denied access to Kiro. Please ensure you grant all required permissions.",
126-
provider
127-
)
124+
format!("{provider} denied access to Kiro. Please ensure you grant all required permissions.")
128125
},
129126
"invalid_request" => "Authentication failed due to an invalid request. Please try again.".to_string(),
130127
"unauthorized_client" => "The application is not authorized. Please contact support.".to_string(),
131128
"server_error" => {
132-
format!("{} login is temporarily unavailable. Please try again later.", provider)
129+
format!("{provider} login is temporarily unavailable. Please try again later.")
133130
},
134131
"invalid_scope" => "The requested permissions are invalid. Please contact support.".to_string(),
135132
_ => {
136133
// For unknown errors, use cleaned description or a generic message
137-
cleaned_description.unwrap_or_else(|| format!("Authentication failed: {}. Please try again.", error_code))
134+
cleaned_description.unwrap_or_else(|| format!("Authentication failed: {error_code}. Please try again."))
138135
},
139136
}
140137
}
@@ -183,7 +180,7 @@ async fn process_portal_callback(
183180
idc_region: sso_region,
184181
})
185182
},
186-
other => Err(AuthError::OAuthCustomError(format!("Unknown login_option: {}", other))),
183+
other => Err(AuthError::OAuthCustomError(format!("Unknown login_option: {other}"))),
187184
}
188185
}
189186

@@ -217,12 +214,12 @@ fn extract_sso_params(callback: &AuthPortalCallback, auth_type: &str) -> Result<
217214
let issuer_url = callback
218215
.issuer_url
219216
.clone()
220-
.ok_or_else(|| AuthError::OAuthCustomError(format!("Missing issuer_url for {} auth", auth_type)))?;
217+
.ok_or_else(|| AuthError::OAuthCustomError(format!("Missing issuer_url for {auth_type} auth")))?;
221218

222219
let sso_region = callback
223220
.sso_region
224221
.clone()
225-
.ok_or_else(|| AuthError::OAuthCustomError(format!("Missing sso_region for {} auth", auth_type)))?;
222+
.ok_or_else(|| AuthError::OAuthCustomError(format!("Missing sso_region for {auth_type} auth")))?;
226223

227224
Ok((issuer_url, sso_region))
228225
}
@@ -357,7 +354,7 @@ async fn handle_invalid_callback(path: &str) -> Result<Response<Full<Bytes>>, Au
357354

358355
/// Build a redirect response to the auth portal
359356
fn build_redirect_response(status: &str, error_message: Option<&str>) -> Result<Response<Full<Bytes>>, AuthError> {
360-
let mut redirect_url = format!("{}?auth_status={}&redirect_from=kirocli", AUTH_PORTAL_URL, status);
357+
let mut redirect_url = format!("{AUTH_PORTAL_URL}?auth_status={status}&redirect_from=kirocli");
361358

362359
if let Some(msg) = error_message {
363360
redirect_url.push_str(&format!("&error_message={}", urlencoding::encode(msg)));

crates/chat-cli/src/auth/social.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl SocialToken {
150150

151151
let client = Client::new();
152152
let response = client
153-
.post(format!("{}/refreshToken", SOCIAL_AUTH_SERVICE_ENDPOINT))
153+
.post(format!("{SOCIAL_AUTH_SERVICE_ENDPOINT}/refreshToken"))
154154
.header("Content-Type", "application/json")
155155
.header("User-Agent", USER_AGENT)
156156
.json(&serde_json::json!({
@@ -201,7 +201,7 @@ impl SocialToken {
201201
});
202202

203203
let response = client
204-
.post(format!("{}/oauth/token", SOCIAL_AUTH_SERVICE_ENDPOINT))
204+
.post(format!("{SOCIAL_AUTH_SERVICE_ENDPOINT}/oauth/token"))
205205
.header("Content-Type", "application/json")
206206
.header("User-Agent", USER_AGENT)
207207
.json(&token_request)
@@ -214,8 +214,7 @@ impl SocialToken {
214214

215215
error!("Token exchange failed: {} - {}", status, body);
216216
return Err(AuthError::SocialAuthProviderFailure(format!(
217-
"Token exchange failed: {}",
218-
body
217+
"Token exchange failed: {body}"
219218
)));
220219
}
221220
let token_response: TokenResponse = response.json().await?;

crates/chat-cli/src/cli/user.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl LoginArgs {
105105
]);
106106
match start_unified_auth(&mut os.database).await? {
107107
PortalResult::Social(provider) => {
108-
pre_portal_spinner.stop_with_message(format!("Logged in with {}", provider));
108+
pre_portal_spinner.stop_with_message(format!("Logged in with {provider}"));
109109
os.telemetry.send_user_logged_in().ok();
110110
return Ok(ExitCode::SUCCESS);
111111
},

0 commit comments

Comments
 (0)