Возможность не указывать профиль при авторизации

This commit is contained in:
Gravit 2018-11-04 11:35:42 +07:00
parent 7a7abd09bd
commit d845b73c85
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
3 changed files with 19 additions and 12 deletions

View file

@ -40,7 +40,10 @@ public AuthResponse(LaunchServer server, long session, HInput input, HOutput out
@Override
public void reply() throws Exception {
String login = input.readString(SerializeLimits.MAX_LOGIN);
String client = input.readString(SerializeLimits.MAX_CLIENT);
boolean isClient = input.readBoolean();
String client = null;
if(isClient)
client = input.readString(SerializeLimits.MAX_CLIENT);
int auth_id = input.readInt();
long hwid_hdd = input.readLong();
long hwid_cpu = input.readLong();
@ -73,17 +76,19 @@ public void reply() throws Exception {
AuthProvider.authError(String.format("Illegal result: '%s'", result.username));
return;
}
Collection<SignedObjectHolder<ClientProfile>> profiles = server.getProfiles();
for (SignedObjectHolder<ClientProfile> p : profiles) {
if (p.object.getTitle().equals(client)) {
if (!p.object.isWhitelistContains(login)) {
throw new AuthException(server.config.whitelistRejectString);
if(isClient) {
Collection<SignedObjectHolder<ClientProfile>> profiles = server.getProfiles();
for (SignedObjectHolder<ClientProfile> p : profiles) {
if (p.object.getTitle().equals(client)) {
if (!p.object.isWhitelistContains(login)) {
throw new AuthException(server.config.whitelistRejectString);
}
clientData.profile = p.object;
}
clientData.profile = p.object;
}
}
if(clientData.profile == null) {
throw new AuthException("You profile not found");
if (clientData.profile == null) {
throw new AuthException("You profile not found");
}
}
server.config.hwidHandler.check(HWID.gen(hwid_hdd, hwid_bios, hwid_cpu), result.username);
} catch (AuthException | HWIDException e) {

View file

@ -28,7 +28,7 @@ private static Texture getTexture(String url, boolean cloak) throws IOException
private static String getTextureURL(String url, UUID uuid, String username, String client) {
return CommonHelper.replace(url, "username", IOHelper.urlEncode(username),
"uuid", IOHelper.urlEncode(uuid.toString()), "hash", IOHelper.urlEncode(Launcher.toHash(uuid)),
"client", IOHelper.urlEncode(client));
"client", IOHelper.urlEncode(client == null ? "unknown" : client));
}
// Instance

View file

@ -67,7 +67,9 @@ public Integer getType() {
@Override
protected Result requestDo(HInput input, HOutput output) throws IOException {
output.writeString(login, SerializeLimits.MAX_LOGIN);
output.writeString(Launcher.profile.getTitle(), SerializeLimits.MAX_CLIENT);
output.writeBoolean(Launcher.profile != null);
if(Launcher.profile != null)
output.writeString(Launcher.profile.getTitle(), SerializeLimits.MAX_CLIENT);
output.writeInt(auth_id);
output.writeLong(Launcher.isUsingAvanguard() ? GuardBind.avnGetHddId() : 0);
output.writeLong(Launcher.isUsingAvanguard() ? GuardBind.avnGetCpuid() : 0);