forked from GeyserMC/Geyser
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
By refering the commit GeyserMC#4147, revert the mojang login function.
- Loading branch information
Showing
7 changed files
with
75 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,12 +34,14 @@ | |
import org.cloudburstmc.protocol.bedrock.util.ChainValidationResult; | ||
import org.cloudburstmc.protocol.bedrock.util.ChainValidationResult.IdentityData; | ||
import org.cloudburstmc.protocol.bedrock.util.EncryptionUtils; | ||
import org.geysermc.cumulus.form.CustomForm; | ||
import org.geysermc.cumulus.form.ModalForm; | ||
import org.geysermc.cumulus.form.SimpleForm; | ||
import org.geysermc.cumulus.response.SimpleFormResponse; | ||
import org.geysermc.cumulus.response.result.FormResponseResult; | ||
import org.geysermc.cumulus.response.result.ValidFormResponseResult; | ||
import org.geysermc.geyser.GeyserImpl; | ||
import org.geysermc.geyser.configuration.GeyserConfiguration; | ||
import org.geysermc.geyser.session.GeyserSession; | ||
import org.geysermc.geyser.session.auth.AuthData; | ||
import org.geysermc.geyser.session.auth.BedrockClientData; | ||
|
@@ -135,20 +137,31 @@ public static void buildAndShowLoginWindow(GeyserSession session) { | |
// Set DoDaylightCycle to false so the time doesn't accelerate while we're here | ||
session.setDaylightCycle(false); | ||
|
||
GeyserConfiguration config = session.getGeyser().getConfig(); | ||
boolean isPasswordAuthEnabled = config.getRemote().isPasswordAuthentication(); | ||
|
||
session.sendForm( | ||
SimpleForm.builder() | ||
.translator(GeyserLocale::getPlayerLocaleString, session.locale()) | ||
.title("geyser.auth.login.form.notice.title") | ||
.content("geyser.auth.login.form.notice.desc") | ||
.optionalButton("geyser.auth.login.form.notice.btn_login.mojang", isPasswordAuthEnabled) | ||
.button("geyser.auth.login.form.notice.btn_login.microsoft") | ||
.button("geyser.auth.login.form.notice.btn_disconnect") | ||
.closedOrInvalidResultHandler(() -> buildAndShowLoginWindow(session)) | ||
.validResultHandler((response) -> { | ||
if (response.clickedButtonId() == 0) { | ||
if (response.clickedButtonId() == 0){ | ||
buildAndShowLoginDetailsWindow(session); | ||
return; | ||
} | ||
|
||
if (response.clickedButtonId() == 1) { | ||
session.authenticateWithMicrosoftCode(); | ||
return; | ||
} | ||
|
||
|
||
|
||
session.disconnect(GeyserLocale.getPlayerLocaleString("geyser.auth.login.form.disconnect", session.locale())); | ||
})); | ||
} | ||
|
@@ -199,6 +212,18 @@ private static BiConsumer<SimpleForm, FormResponseResult<SimpleFormResponse>> au | |
} | ||
}; | ||
} | ||
public static void buildAndShowLoginDetailsWindow(GeyserSession session) { | ||
session.sendForm( | ||
CustomForm.builder() | ||
.translator(GeyserLocale::getPlayerLocaleString, session.locale()) | ||
.title("geyser.auth.login.form.details.title") | ||
.label("geyser.auth.login.form.details.desc") | ||
.input("geyser.auth.login.form.details.email", "[email protected]", "") | ||
.input("geyser.auth.login.form.details.pass", "123456", "") | ||
.invalidResultHandler(() -> buildAndShowLoginDetailsWindow(session)) | ||
.closedResultHandler(() -> buildAndShowLoginWindow(session)) | ||
.validResultHandler((response) -> session.authenticate(response.next(), response.next()))); | ||
} | ||
|
||
/** | ||
* Shows the code that a user must input into their browser | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters