Skip to content

Commit

Permalink
Merge pull request #173 from Lyzev/172-bug-microsoft-account-web-login
Browse files Browse the repository at this point in the history
fixed msa web login bug
  • Loading branch information
Lyzev authored Jul 7, 2024
2 parents 143ffba + e2ac67c commit 7d0b32c
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions src/main/kotlin/dev/lyzev/api/account/accounts/AccountMicrosoft.kt
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class AccountMicrosoft(var session: StepFullJavaSession.FullJavaSession) : Accou
private val emailRegex = Regex("^[\\w-.]+@([\\w-]+\\.)+[\\w-]{2,4}$")
private val password = ImString("", 64)
private var isHidden = true
private var canUseDeviceCode = true
private var msg: String? = null
private val timeAnimator = TimeAnimator(4000)

Expand Down Expand Up @@ -147,20 +146,16 @@ class AccountMicrosoft(var session: StepFullJavaSession.FullJavaSession) : Accou
}
sameLine()
if (ImGuiScreenAccountManager.button(FontAwesomeIcons.Globe, "Add the account using a device code.")) {
if (canUseDeviceCode) {
thread {
canUseDeviceCode = false
val httpClient = MinecraftAuth.createHttpClient()
val javaSession = MinecraftAuth.JAVA_DEVICE_CODE_LOGIN.getFromInput(
httpClient,
MsaDeviceCodeCallback { msaDeviceCode: MsaDeviceCode ->
Schizoid.logger.info("Go to " + msaDeviceCode.verificationUri)
Schizoid.logger.info("Enter code " + msaDeviceCode.userCode)
Desktop.getDesktop().browse(URI(msaDeviceCode.directVerificationUri))
})
ImGuiScreenAccountManager.accounts += AccountMicrosoft(session = javaSession)
canUseDeviceCode = true
}
thread {
val httpClient = MinecraftAuth.createHttpClient()
val javaSession = MinecraftAuth.JAVA_DEVICE_CODE_LOGIN.getFromInput(
httpClient,
MsaDeviceCodeCallback { msaDeviceCode: MsaDeviceCode ->
Schizoid.logger.info("Go to " + msaDeviceCode.verificationUri)
Schizoid.logger.info("Enter code " + msaDeviceCode.userCode)
Desktop.getDesktop().browse(URI(msaDeviceCode.directVerificationUri))
})
ImGuiScreenAccountManager.accounts += AccountMicrosoft(session = javaSession)
}
}
sameLine()
Expand Down

0 comments on commit 7d0b32c

Please sign in to comment.