Skip to content

Commit 6f167a8

Browse files
committed
Review comments
1 parent 048acdb commit 6f167a8

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

crates/data-model/src/users.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ impl User {
4747
}
4848
}
4949

50-
impl Display for User {
51-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
52-
// Format the user as their username, this is useful for logging and
53-
// debugging.
54-
self.username.fmt(f)
55-
}
56-
}
57-
5850
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
5951
pub struct Password {
6052
pub id: Ulid,

crates/handlers/src/views/login.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ pub(crate) async fn post(
190190
// First, lookup the user
191191
let Some(user) = get_user_by_email_or_by_username(site_config, &mut repo, username).await?
192192
else {
193-
tracing::warn!("User not found: {username}");
193+
tracing::warn!(username, "User not found");
194194
let form_state = form_state.with_error_on_form(FormError::InvalidCredentials);
195195
PASSWORD_LOGIN_COUNTER.add(1, &[KeyValue::new(RESULT, "error")]);
196196
return render(
@@ -209,7 +209,7 @@ pub(crate) async fn post(
209209

210210
// Check the rate limit
211211
if let Err(e) = limiter.check_password(requester, &user) {
212-
tracing::warn!(error = &e as &dyn std::error::Error);
212+
tracing::warn!(error = &e as &dyn std::error::Error, "ratelimit exceeded");
213213
let form_state = form_state.with_error_on_form(FormError::RateLimitExceeded);
214214
PASSWORD_LOGIN_COUNTER.add(1, &[KeyValue::new(RESULT, "error")]);
215215
return render(
@@ -230,7 +230,7 @@ pub(crate) async fn post(
230230
let Some(user_password) = repo.user_password().active(&user).await? else {
231231
// There is no password for this user, but we don't want to disclose that. Show
232232
// a generic 'invalid credentials' error instead
233-
tracing::warn!("No password for user: {user}");
233+
tracing::warn!(username, "No password for user");
234234
let form_state = form_state.with_error_on_form(FormError::InvalidCredentials);
235235
PASSWORD_LOGIN_COUNTER.add(1, &[KeyValue::new(RESULT, "error")]);
236236
return render(
@@ -274,7 +274,7 @@ pub(crate) async fn post(
274274
}
275275
Ok(PasswordVerificationResult::Success(None)) => user_password,
276276
Ok(PasswordVerificationResult::Failure) => {
277-
tracing::warn!("Failed to verify/upgrade password for user: {user}");
277+
tracing::warn!(username, "Failed to verify/upgrade password for user");
278278
let form_state = form_state.with_error_on_form(FormError::InvalidCredentials);
279279
PASSWORD_LOGIN_COUNTER.add(1, &[KeyValue::new(RESULT, "mismatch")]);
280280
return render(
@@ -296,7 +296,7 @@ pub(crate) async fn post(
296296
// Now that we have checked the user password, we now want to show an error if
297297
// the user is locked or deactivated
298298
if user.deactivated_at.is_some() {
299-
tracing::warn!("User is deactivated: {user}");
299+
tracing::warn!(username, "User is deactivated");
300300
PASSWORD_LOGIN_COUNTER.add(1, &[KeyValue::new(RESULT, "error")]);
301301
let (csrf_token, cookie_jar) = cookie_jar.csrf_token(&clock, &mut rng);
302302
let ctx = AccountInactiveContext::new(user)
@@ -307,7 +307,7 @@ pub(crate) async fn post(
307307
}
308308

309309
if user.locked_at.is_some() {
310-
tracing::warn!("User is locked: {user}");
310+
tracing::warn!(username, "User is locked");
311311
PASSWORD_LOGIN_COUNTER.add(1, &[KeyValue::new(RESULT, "error")]);
312312
let (csrf_token, cookie_jar) = cookie_jar.csrf_token(&clock, &mut rng);
313313
let ctx = AccountInactiveContext::new(user)

0 commit comments

Comments
 (0)