Skip to content

Commit 24eba42

Browse files
committed
Simplify if statement
1 parent 426fb95 commit 24eba42

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/main/java/httpserver/Authorizer.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@
44

55
public class Authorizer {
66
public boolean authorize(Request request) {
7-
if (request.hasHeader("Authorization")) {
8-
String authorizationHeader = request.getHeaderValue("Authorization");
9-
String[] credentials = decodeBasicAuthHeader(authorizationHeader);
10-
11-
if (validateCredentials(credentials)) {
12-
return true;
13-
}
14-
else {
15-
return false;
16-
}
7+
if (!request.hasHeader("Authorization")) {
8+
return false;
179
}
18-
return false;
10+
11+
String authorizationHeader = request.getHeaderValue("Authorization");
12+
String[] credentials = decodeBasicAuthHeader(authorizationHeader);
13+
14+
return validateCredentials(credentials);
1915
}
2016

2117
private boolean validateCredentials(String[] credentials) {

0 commit comments

Comments
 (0)