[FIX] HttpAuthCoreProvider small fixes

This commit is contained in:
Gravita 2022-06-08 23:17:35 +07:00
parent 6fac47f99d
commit 0b38781858
2 changed files with 5 additions and 2 deletions

View file

@ -29,6 +29,9 @@ public HttpHelper.HttpOptional<T, SimpleError> applyJson(JsonElement response, i
if(statusCode < 200 || statusCode >= 300) {
return new HttpHelper.HttpOptional<>(null, Launcher.gsonManager.gson.fromJson(response, SimpleError.class), statusCode);
}
if(type == Void.class) {
return new HttpHelper.HttpOptional<>(null, null, statusCode);
}
return new HttpHelper.HttpOptional<>(Launcher.gsonManager.gson.fromJson(response, type), null, statusCode);
}
}

View file

@ -150,12 +150,12 @@ protected boolean updateServerID(User user, String serverID) throws IOException
@Override
public User checkServer(Client client, String username, String serverID) throws IOException {
return requester.send(requester.post(checkServerUrl, new CheckServerRequest(username, serverID), null), HttpUser.class).getOrThrow();
return requester.send(requester.post(checkServerUrl, new CheckServerRequest(username, serverID), bearerToken), HttpUser.class).getOrThrow();
}
@Override
public boolean joinServer(Client client, String username, String accessToken, String serverID) throws IOException {
var result = requester.send(requester.post(joinServerUrl, new JoinServerRequest(username, accessToken, serverID), null), Void.class);
var result = requester.send(requester.post(joinServerUrl, new JoinServerRequest(username, accessToken, serverID), bearerToken), Void.class);
return result.isSuccessful();
}