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

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 @Override
public void reply() throws Exception { public void reply() throws Exception {
String login = input.readString(SerializeLimits.MAX_LOGIN); 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(); int auth_id = input.readInt();
long hwid_hdd = input.readLong(); long hwid_hdd = input.readLong();
long hwid_cpu = input.readLong(); long hwid_cpu = input.readLong();
@ -73,6 +76,7 @@ public void reply() throws Exception {
AuthProvider.authError(String.format("Illegal result: '%s'", result.username)); AuthProvider.authError(String.format("Illegal result: '%s'", result.username));
return; return;
} }
if(isClient) {
Collection<SignedObjectHolder<ClientProfile>> profiles = server.getProfiles(); Collection<SignedObjectHolder<ClientProfile>> profiles = server.getProfiles();
for (SignedObjectHolder<ClientProfile> p : profiles) { for (SignedObjectHolder<ClientProfile> p : profiles) {
if (p.object.getTitle().equals(client)) { if (p.object.getTitle().equals(client)) {
@ -82,9 +86,10 @@ public void reply() throws Exception {
clientData.profile = p.object; clientData.profile = p.object;
} }
} }
if(clientData.profile == null) { if (clientData.profile == null) {
throw new AuthException("You profile not found"); throw new AuthException("You profile not found");
} }
}
server.config.hwidHandler.check(HWID.gen(hwid_hdd, hwid_bios, hwid_cpu), result.username); server.config.hwidHandler.check(HWID.gen(hwid_hdd, hwid_bios, hwid_cpu), result.username);
} catch (AuthException | HWIDException e) { } catch (AuthException | HWIDException e) {
requestError(e.getMessage()); requestError(e.getMessage());

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) { private static String getTextureURL(String url, UUID uuid, String username, String client) {
return CommonHelper.replace(url, "username", IOHelper.urlEncode(username), return CommonHelper.replace(url, "username", IOHelper.urlEncode(username),
"uuid", IOHelper.urlEncode(uuid.toString()), "hash", IOHelper.urlEncode(Launcher.toHash(uuid)), "uuid", IOHelper.urlEncode(uuid.toString()), "hash", IOHelper.urlEncode(Launcher.toHash(uuid)),
"client", IOHelper.urlEncode(client)); "client", IOHelper.urlEncode(client == null ? "unknown" : client));
} }
// Instance // Instance

View file

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