Skip to content

Commit 12bed75

Browse files
committed
user/middleware: Move tx variable further down
There is no need in initializing that variable if the request doesn't have the Authorization header
1 parent 6aa2cff commit 12bed75

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/user/middleware.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ impl conduit_middleware::Middleware for Middleware {
3232
None => {
3333

3434
// Look for an `Authorization` header on the request
35-
let tx = try!(req.tx().map_err(std_error));
3635
match req.headers().find("Authorization") {
3736
Some(headers) => {
3837

3938
// Look for a user in the database with a matching API token
39+
let tx = try!(req.tx().map_err(std_error));
4040
match User::find_by_api_token(tx, &headers[0]) {
4141
Ok(user) => user,
4242
Err(..) => return Ok(())

0 commit comments

Comments
 (0)