Skip to content

Commit 600f505

Browse files
committed
Add some error chaining to log more on auth failure
1 parent f17f2dd commit 600f505

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/controllers/util.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,12 @@ impl<'a> UserAuthenticationExt for dyn Request + 'a {
4242
user_id: token.user_id,
4343
token_id: Some(token.id),
4444
})
45-
// Convert a NotFound (or other database error) into Unauthorized
46-
.map_err(|_| Box::new(Unauthorized) as Box<dyn AppError>)
45+
.chain_error(|| internal("invalid token"))
46+
.chain_error(|| Box::new(Unauthorized) as Box<dyn AppError>)
4747
} else {
4848
// Unable to authenticate the user
49-
Err(Box::new(Unauthorized))
49+
Err(internal("no cookie session or auth header found"))
50+
.chain_error(|| Box::new(Unauthorized) as Box<dyn AppError>)
5051
}
5152
}
5253
}

0 commit comments

Comments
 (0)