mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
fixing linking account problems on oculus/steam, changing callback
This commit is contained in:
parent
bb61334c0d
commit
ef63213d28
9 changed files with 59 additions and 50 deletions
|
@ -287,6 +287,8 @@ Item {
|
|||
case Qt.Key_Return:
|
||||
event.accepted = true;
|
||||
loginDialog.createAccountFromOculus(emailField.text, usernameField.text, passwordField.text);
|
||||
bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": completeProfileBody.withSteam,
|
||||
"linkSteam": false, "withOculus": completeProfileBody.withOculus, "linkOculus": false, "createOculus": true });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -434,7 +436,6 @@ Item {
|
|||
linkColor: hifi.colors.blueAccent
|
||||
|
||||
onLinkActivated: {
|
||||
loginDialog.isLogIn = true;
|
||||
bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "errorString": "",
|
||||
"withSteam": completeProfileBody.withSteam, "linkSteam": completeProfileBody.withSteam, "withOculus": completeProfileBody.withOculus,
|
||||
"linkOculus": completeProfileBody.withOculus });
|
||||
|
@ -467,8 +468,10 @@ Item {
|
|||
}
|
||||
onHandleCreateFailed: {
|
||||
console.log("Create Failed: " + error);
|
||||
bodyLoader.setSource("UsernameCollisionBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": completeProfileBody.withSteam,
|
||||
"withOculus": completeProfileBody.withOculus });
|
||||
if (!completeProfileBody.withOculus) {
|
||||
bodyLoader.setSource("UsernameCollisionBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": completeProfileBody.withSteam,
|
||||
"withOculus": completeProfileBody.withOculus });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,9 +36,9 @@ Item {
|
|||
property bool keyboardRaised: false
|
||||
property bool punctuationMode: false
|
||||
|
||||
property bool withSteam: false
|
||||
property bool withSteam: withSteam
|
||||
property bool linkSteam: linkSteam
|
||||
property bool withOculus: false
|
||||
property bool withOculus: withOculus
|
||||
property bool linkOculus: linkOculus
|
||||
property string errorString: errorString
|
||||
property bool lostFocus: false
|
||||
|
|
|
@ -79,17 +79,6 @@ Item {
|
|||
loggingInGlyph.visible = true;
|
||||
loggingInText.text = "Creating account with Oculus";
|
||||
loggingInText.x = loggingInHeader.width/2 - loggingInTextMetrics.width/2 + loggingInGlyphTextMetrics.width/2;
|
||||
} else if (loggingInBody.linkSteam) {
|
||||
loggingInGlyph.visible = true;
|
||||
loggingInText.text = "Linking to Steam";
|
||||
loggingInText.x = loggingInHeader.width/2 - loggingInTextMetrics.width/2 + loggingInGlyphTextMetrics.width/2;
|
||||
loginDialog.linkSteam();
|
||||
} else if (loggingInBody.linkOculus) {
|
||||
loggingInGlyph.text = hifi.glyphs.oculus;
|
||||
loggingInGlyph.visible = true;
|
||||
loggingInText.text = "Linking to Oculus";
|
||||
loggingInText.x = loggingInHeader.width/2 - loggingInTextMetrics.width/2 + loggingInGlyphTextMetrics.width/2;
|
||||
loginDialog.linkOculus();
|
||||
} else if (loggingInBody.withSteam) {
|
||||
loggingInGlyph.visible = true;
|
||||
loggingInText.text = "Logging in to Steam";
|
||||
|
@ -106,16 +95,18 @@ Item {
|
|||
loggingInSpinner.visible = true;
|
||||
}
|
||||
function loadingSuccess() {
|
||||
loggingInSpinner.visible = false;
|
||||
if (loggingInBody.linkSteam) {
|
||||
loggingInText.text = "Linking to Steam";
|
||||
loggingInText.x = loggingInHeader.width/2 - loggingInTextMetrics.width/2 + loggingInGlyphTextMetrics.width/2;
|
||||
loginDialog.linkSteam();
|
||||
return;
|
||||
} else if (loggingInBody.linkOculus) {
|
||||
loggingInText.text = "Linking to Oculus";
|
||||
loggingInText.x = loggingInHeader.width/2 - loggingInTextMetrics.width/2 + loggingInGlyphTextMetrics.width/2;
|
||||
loginDialog.linkOculus();
|
||||
return;
|
||||
}
|
||||
loggingInSpinner.visible = false;
|
||||
if (loggingInBody.withSteam) {
|
||||
// reset the flag.
|
||||
loggingInGlyph.visible = false;
|
||||
|
@ -237,6 +228,23 @@ Item {
|
|||
verticalAlignment: Text.AlignVCenter;
|
||||
visible: false;
|
||||
}
|
||||
HifiControlsUit.Button {
|
||||
id: okButton;
|
||||
width: d.minWidthButton
|
||||
height: d.minHeightButton
|
||||
text: qsTr("OK")
|
||||
color: hifi.buttons.white
|
||||
anchors {
|
||||
top: loggedInGlyph.bottom
|
||||
topMargin: 3 * hifi.dimensions.contentSpacing.y
|
||||
left: parent.left
|
||||
leftMargin: (parent.width - width) / 2;
|
||||
}
|
||||
onClicked: {
|
||||
root.tryDestroy();
|
||||
}
|
||||
visible: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -271,8 +279,14 @@ Item {
|
|||
}
|
||||
onHandleLinkFailed: {
|
||||
console.log("Link Failed: " + error);
|
||||
bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "linkSteam": loggingInBody.linkSteam,
|
||||
"linkOculus": loggingInBody.linkOculus, "errorString": error });
|
||||
loggingInSpinner.visible = false;
|
||||
if (loggingInBody.linkOculus) {
|
||||
loggingInText.text = "Oculus failed to link";
|
||||
okButton.visible = true;
|
||||
} else {
|
||||
bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "linkSteam": loggingInBody.linkSteam,
|
||||
"linkOculus": loggingInBody.linkOculus, "errorString": error });
|
||||
}
|
||||
}
|
||||
|
||||
onHandleLoginCompleted: {
|
||||
|
@ -288,19 +302,19 @@ Item {
|
|||
if (loggingInBody.linkOculus && loggingInBody.withOculus) {
|
||||
errorString = "Username or password is incorrect.";
|
||||
bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": loggingInBody.withSteam,
|
||||
"withOculus": loggingInBody.withOculus, "linkSteam": loggingInBody.linkSteam, "errorString": errorString });
|
||||
"withOculus": loggingInBody.withOculus, "linkSteam": loggingInBody.linkSteam, "linkOculus": loggingInBody.linkOculus, "errorString": errorString });
|
||||
} else if (loggingInBody.linkSteam && loggingInBody.withSteam) {
|
||||
errorString = "Username or password is incorrect.";
|
||||
bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": loggingInBody.withSteam,
|
||||
"withOculus": loggingInBody.withOculus, "linkSteam": loggingInBody.linkSteam, "errorString": errorString });
|
||||
"withOculus": loggingInBody.withOculus, "linkSteam": loggingInBody.linkSteam, "linkOculus": loggingInBody.linkOculus, "errorString": errorString });
|
||||
} else if (loggingInBody.withSteam) {
|
||||
errorString = "Your Steam authentication has failed. Please make sure you are logged into Steam and try again.";
|
||||
bodyLoader.setSource("CompleteProfileBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": loggingInBody.withSteam,
|
||||
"withOculus": loggingInBody.withOculus, "errorString": errorString });
|
||||
"withOculus": loggingInBody.withOculus, "linkSteam": loggingInBody.linkSteam, "linkOculus": loggingInBody.linkOculus, "errorString": errorString });
|
||||
} else if (loggingInBody.withOculus) {
|
||||
errorString = "Your Oculus account is not connected to an existing High Fidelity account. Please create a new one."
|
||||
bodyLoader.setSource("CompleteProfileBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": loggingInBody.withSteam,
|
||||
"withOculus": loggingInBody.withOculus, "errorString": errorString });
|
||||
"withOculus": loggingInBody.withOculus, "linkSteam": loggingInBody.linkSteam, "linkOculus": loggingInBody.linkOculus, "errorString": errorString });
|
||||
} else {
|
||||
errorString = "Username or password is incorrect.";
|
||||
bodyLoader.setSource("LinkAccountBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "errorString": errorString });
|
||||
|
|
|
@ -138,8 +138,8 @@ void LoginDialog::login(const QString& username, const QString& password) const
|
|||
void LoginDialog::loginThroughOculus() {
|
||||
qDebug() << "Attempting to login through Oculus";
|
||||
if (auto oculusPlatformPlugin = PluginManager::getInstance()->getOculusPlatformPlugin()) {
|
||||
oculusPlatformPlugin->requestNonceAndUserID([this] (QString nonce, QString userID, QString oculusID) {
|
||||
DependencyManager::get<AccountManager>()->requestAccessTokenWithOculus(nonce, userID, oculusID);
|
||||
oculusPlatformPlugin->requestNonceAndUserID([this] (QString nonce, QString oculusID) {
|
||||
DependencyManager::get<AccountManager>()->requestAccessTokenWithOculus(nonce, oculusID);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -147,8 +147,8 @@ void LoginDialog::loginThroughOculus() {
|
|||
void LoginDialog::linkOculus() {
|
||||
qDebug() << "Attempting to link Oculus account";
|
||||
if (auto oculusPlatformPlugin = PluginManager::getInstance()->getOculusPlatformPlugin()) {
|
||||
oculusPlatformPlugin->requestNonceAndUserID([this] (QString nonce, QString userID, QString oculusID) {
|
||||
if (nonce.isEmpty() || userID.isEmpty() || oculusID.isEmpty()) {
|
||||
oculusPlatformPlugin->requestNonceAndUserID([this] (QString nonce, QString oculusID) {
|
||||
if (nonce.isEmpty() || oculusID.isEmpty()) {
|
||||
emit handleLoginFailed();
|
||||
return;
|
||||
}
|
||||
|
@ -174,8 +174,8 @@ void LoginDialog::linkOculus() {
|
|||
void LoginDialog::createAccountFromOculus(QString email, QString username, QString password) {
|
||||
qDebug() << "Attempting to create account from Oculus info";
|
||||
if (auto oculusPlatformPlugin = PluginManager::getInstance()->getOculusPlatformPlugin()) {
|
||||
oculusPlatformPlugin->requestNonceAndUserID([this, email, username, password] (QString nonce, QString userID, QString oculusID) {
|
||||
if (nonce.isEmpty() || userID.isEmpty() || oculusID.isEmpty()) {
|
||||
oculusPlatformPlugin->requestNonceAndUserID([this, email, username, password] (QString nonce, QString oculusID) {
|
||||
if (nonce.isEmpty() || oculusID.isEmpty()) {
|
||||
emit handleLoginFailed();
|
||||
return;
|
||||
}
|
||||
|
@ -307,14 +307,12 @@ void LoginDialog::createFailed(QNetworkReply* reply) {
|
|||
auto root = doc.object();
|
||||
auto data = root.value("data").toObject();
|
||||
auto error = data.value("error").toObject();
|
||||
auto identity = error.value("identity");
|
||||
auto oculusError = data.value("oculus");
|
||||
auto user = error.value("username");
|
||||
auto uid = error.value("uid");
|
||||
auto email = error.value("email");
|
||||
QString usernameError;
|
||||
QString emailError;
|
||||
QString identityError;
|
||||
QString errorReply;
|
||||
if (!uid.isNull() && !uid.isUndefined()) {
|
||||
QJsonArray arr = uid.toArray();
|
||||
if (!arr.isEmpty()) {
|
||||
|
@ -335,25 +333,19 @@ void LoginDialog::createFailed(QNetworkReply* reply) {
|
|||
}
|
||||
}
|
||||
if (!usernameError.isEmpty()) {
|
||||
errorReply = usernameError;
|
||||
if (!emailError.isEmpty()) {
|
||||
errorReply.append(" " + emailError);
|
||||
usernameError.append(" " + emailError);
|
||||
}
|
||||
emit handleCreateFailed(errorReply);
|
||||
emit handleCreateFailed(usernameError);
|
||||
return;
|
||||
}
|
||||
if (!emailError.isEmpty()) {
|
||||
emit handleCreateFailed(emailError);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!identity.isNull() && !identity.isUndefined()) {
|
||||
QJsonArray arr = identity.toArray();
|
||||
if (!arr.isEmpty()) {
|
||||
auto identityError = "Identity " + arr.at(0).toString() + ".";
|
||||
emit handleCreateFailed(identityError);
|
||||
return;
|
||||
}
|
||||
if (!oculusError.isNull() && !oculusError.isUndefined()) {
|
||||
emit handleCreateFailed("Could not verify token with Oculus. Please try again.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
emit handleCreateFailed(reply->errorString());
|
||||
|
|
|
@ -588,7 +588,7 @@ void AccountManager::requestAccessTokenWithSteam(QByteArray authSessionTicket) {
|
|||
connect(requestReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(requestAccessTokenError(QNetworkReply::NetworkError)));
|
||||
}
|
||||
|
||||
void AccountManager::requestAccessTokenWithOculus(const QString& nonce, const QString& userID, const QString &oculusID) {
|
||||
void AccountManager::requestAccessTokenWithOculus(const QString& nonce, const QString &oculusID) {
|
||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
|
||||
QNetworkRequest request;
|
||||
|
|
|
@ -106,7 +106,7 @@ public:
|
|||
public slots:
|
||||
void requestAccessToken(const QString& login, const QString& password);
|
||||
void requestAccessTokenWithSteam(QByteArray authSessionTicket);
|
||||
void requestAccessTokenWithOculus(const QString& nonce, const QString& userID, const QString& oculusID);
|
||||
void requestAccessTokenWithOculus(const QString& nonce, const QString& oculusID);
|
||||
void requestAccessTokenWithAuthCode(const QString& authCode,
|
||||
const QString& clientId,
|
||||
const QString& clientSecret,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include <functional>
|
||||
|
||||
using NonceUserIDCallback = std::function<void(QString, QString, QString)>;
|
||||
using NonceUserIDCallback = std::function<void(QString, QString)>;
|
||||
|
||||
class OculusPlatformPlugin {
|
||||
public:
|
||||
|
@ -20,7 +20,7 @@ public:
|
|||
virtual const QString getName() const = 0;
|
||||
virtual const QString getOculusUserID() const = 0;
|
||||
|
||||
virtual const bool isRunning() const = 0;
|
||||
virtual bool isRunning() = 0;
|
||||
|
||||
virtual void requestNonceAndUserID(NonceUserIDCallback callback) = 0;
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ OculusAPIPlugin::~OculusAPIPlugin() {
|
|||
hifi::ovr::releaseRenderSession(_session);
|
||||
}
|
||||
|
||||
const bool OculusAPIPlugin::isRunning() const {
|
||||
bool OculusAPIPlugin::isRunning() {
|
||||
return (qApp->property(hifi::properties::OCULUS_STORE).toBool());
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ void OculusAPIPlugin::handleOVREvents() {
|
|||
}
|
||||
|
||||
if (_nonceChanged) {
|
||||
_nonceUserIDCallback(_nonce, _user, QString::number(_userID));
|
||||
_nonceUserIDCallback(_nonce, QString::number(_userID));
|
||||
_nonceChanged = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
const QString getName() const { return NAME; }
|
||||
const QString getOculusUserID() const { return _user; };
|
||||
|
||||
const bool isRunning() const;
|
||||
bool isRunning();
|
||||
|
||||
virtual void requestNonceAndUserID(NonceUserIDCallback callback);
|
||||
|
||||
|
|
Loading…
Reference in a new issue