Fix Microsoft account provider

This commit is contained in:
Dāvis Mosāns
2021-12-10 05:22:44 +02:00
parent 92e1a0fa08
commit 663e6a313c
7 changed files with 39 additions and 4 deletions

View File

@@ -218,6 +218,7 @@ set(MINECRAFT_SOURCES
minecraft/auth/providers/DummyAuthProvider.h
minecraft/auth/providers/ElybyAuthProvider.h
minecraft/auth/providers/MojangAuthProvider.h
minecraft/auth/providers/MicrosoftAuthProvider.h
minecraft/auth/flows/MSAInteractive.h
minecraft/auth/flows/MSAInteractive.cpp

View File

@@ -313,6 +313,7 @@ bool AccountData::resumeStateFromV3(QJsonObject data) {
auto typeS = typeV.toString();
if(typeS == "MSA") {
type = AccountType::MSA;
provider = AuthProviders::lookup("MSA");
} else {
type = AccountType::Mojang;
provider = AuthProviders::lookup(typeS);

View File

@@ -2,6 +2,7 @@
#include "providers/ElybyAuthProvider.h"
#include "providers/DummyAuthProvider.h"
#include "providers/MojangAuthProvider.h"
#include "providers/MicrosoftAuthProvider.h"
#include "../../AuthServer.h"
#define REGISTER_AUTH_PROVIDER(Provider) \
@@ -20,6 +21,7 @@ namespace AuthProviders
REGISTER_AUTH_PROVIDER(ElybyAuthProvider);
REGISTER_AUTH_PROVIDER(DummyAuthProvider);
REGISTER_AUTH_PROVIDER(MojangAuthProvider);
REGISTER_AUTH_PROVIDER(MicrosoftAuthProvider);
}
AuthProviderPtr lookup(QString id)

View File

@@ -33,6 +33,7 @@
#include "flows/MojangRefresh.h"
#include "flows/MojangLogin.h"
#include "AuthProviders.h"
MinecraftAccountPtr MinecraftAccount::loadFromJsonV2(const QJsonObject& json) {
MinecraftAccountPtr account(new MinecraftAccount());
@@ -63,6 +64,7 @@ MinecraftAccountPtr MinecraftAccount::createBlankMSA()
{
MinecraftAccountPtr account(new MinecraftAccount());
account->data.type = AccountType::MSA;
account->setProvider(AuthProviders::lookup("MSA"));
return account;
}

View File

@@ -18,6 +18,5 @@ void MSAInteractive::executeTask() {
beginActivity(Katabasis::Activity::LoggingIn);
m_oauth2->unlink();
*m_data = AccountData();
m_oauth2->link();
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include <QObject>
#include "QObjectPtr.h"
#include <QDateTime>
#include <QSet>
#include <QProcess>
#include <QDebug>
#include "MojangAuthProvider.h"
class MicrosoftAuthProvider : public MojangAuthProvider
{
Q_OBJECT
public:
QString id()
{
return "MSA";
}
QString displayName()
{
return "Microsoft";
}
};

View File

@@ -28,9 +28,13 @@ LoginDialog::LoginDialog(QWidget *parent) : QDialog(parent), ui(new Ui::LoginDia
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
for(auto provider: AuthProviders::getAll()) {
QRadioButton *button = new QRadioButton(provider->displayName());
m_radioButtons[provider->id()] = button;
ui->radioLayout->addWidget(button);
auto providerId = provider->id();
// Exclude Microsoft account from here...
if (providerId != "MSA") {
QRadioButton *button = new QRadioButton(provider->displayName());
m_radioButtons[providerId] = button;
ui->radioLayout->addWidget(button);
}
}
m_radioButtons["dummy"]->setChecked(true);
adjustSize();