Skip to content

Commit 026a824

Browse files
committed
Fixed bug in AuthenticationAPI. Token refresh requires an existing, valid token which collided with the current auto-login functionality. Session authorization status will now only be set when calling the "/login" route.
1 parent 5999b92 commit 026a824

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/main/java/com/github/m0nk3y2k4/thetvdb/internal/resource/impl/AuthenticationAPI.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ public static void login(@Nonnull APIConnection con) throws APIException {
3838
authentication.put("username", con.getUserName().get());
3939
}
4040

41+
con.setStatus(APISession.Status.AUTHORIZATION_IN_PROGRESS);
4142
setToken(con, () -> con.sendPOST("/login", authentication.toString()));
43+
con.setStatus(APISession.Status.AUTHORIZED);
4244
}
4345

4446
public static void refreshSession(@Nonnull APIConnection con) throws APIException {
4547
setToken(con, () -> con.sendGET("/refresh_token"));
4648
}
4749

4850
private static void setToken(APIConnection con, ThrowingSupplier<JsonNode> sendRequest) throws APIException {
49-
con.setStatus(APISession.Status.AUTHORIZATION_IN_PROGRESS);
50-
5151
// Request token
5252
JsonNode response = sendRequest.get(); // Throws exception if authorization fails
5353
String token = response.get("token").asText();
@@ -57,8 +57,6 @@ private static void setToken(APIConnection con, ThrowingSupplier<JsonNode> sendR
5757

5858
// Set token on connection
5959
con.setToken(token);
60-
61-
con.setStatus(APISession.Status.AUTHORIZED);
6260
}
6361

6462
/**

0 commit comments

Comments
 (0)