mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
linking oculus acct creation to spinner
This commit is contained in:
parent
8c2dee20a0
commit
f983d16cc1
5 changed files with 53 additions and 31 deletions
|
@ -77,7 +77,7 @@ Item {
|
|||
height: loginErrorMessageTextMetrics.height
|
||||
anchors {
|
||||
bottom: buttons.top;
|
||||
bottomMargin: hifi.dimensions.contentSpacing.y;
|
||||
bottomMargin: 2 * hifi.dimensions.contentSpacing.y;
|
||||
left: buttons.left;
|
||||
}
|
||||
TextMetrics {
|
||||
|
@ -102,10 +102,14 @@ Item {
|
|||
loginErrorMessage.wrapMode = Text.WordWrap;
|
||||
loginErrorMessage.verticalAlignment = Text.AlignLeft;
|
||||
loginErrorMessage.horizontalAlignment = Text.AlignLeft;
|
||||
errorContainer.height = 3 * loginErrorMessageTextMetrics.height;
|
||||
errorContainer.height = (loginErrorMessageTextMetrics.width / root.bannerWidth) * loginErrorMessageTextMetrics.height;
|
||||
} else {
|
||||
loginErrorMessage.wrapMode = Text.NoWrap;
|
||||
errorContainer.height = loginErrorMessageTextMetrics.height;
|
||||
}
|
||||
if (completeProfileBody.withOculus) {
|
||||
errorContainer.anchors.bottom = fields.top;
|
||||
errorContainer.anchors.bottomMargin = hifi.dimensions.contentSpacing.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -153,6 +157,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;
|
||||
}
|
||||
}
|
||||
|
@ -200,6 +206,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;
|
||||
}
|
||||
}
|
||||
|
@ -337,6 +345,8 @@ Item {
|
|||
loginErrorMessage.visible = false;
|
||||
if (completeProfileBody.withOculus) {
|
||||
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 });
|
||||
} else if (completeProfileBody.withSteam) {
|
||||
loginDialog.createAccountFromSteam();
|
||||
}
|
||||
|
@ -452,10 +462,8 @@ Item {
|
|||
Connections {
|
||||
target: loginDialog
|
||||
onHandleCreateCompleted: {
|
||||
console.log("Create Succeeded")
|
||||
if (completeProfileBody.withOculus) {
|
||||
loginDialog.loginThroughOculus();
|
||||
} else if (completeProfileBody.withSteam) {
|
||||
console.log("Create Succeeded");
|
||||
if (completeProfileBody.withSteam) {
|
||||
loginDialog.loginThroughSteam();
|
||||
}
|
||||
bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": completeProfileBody.withSteam, "linkSteam": false,
|
||||
|
@ -463,23 +471,8 @@ Item {
|
|||
}
|
||||
onHandleCreateFailed: {
|
||||
console.log("Create Failed: " + error);
|
||||
if (completeProfileBody.withOculus) {
|
||||
loginErrorMessage.visible = true;
|
||||
loginErrorMessage.text = error;
|
||||
|
||||
if (loginErrorMessageTextMetrics.width > root.bannerWidth) {
|
||||
loginErrorMessage.wrapMode = Text.WordWrap;
|
||||
loginErrorMessage.verticalAlignment = Text.AlignLeft;
|
||||
loginErrorMessage.horizontalAlignment = Text.AlignLeft;
|
||||
errorContainer.height = (loginErrorMessageTextMetrics.width / root.bannerWidth) * loginErrorMessageTextMetrics.height;
|
||||
} else {
|
||||
loginErrorMessage.wrapMode = Text.NoWrap;
|
||||
errorContainer.height = loginErrorMessageTextMetrics.height;
|
||||
}
|
||||
} else {
|
||||
bodyLoader.setSource("UsernameCollisionBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": completeProfileBody.withSteam,
|
||||
"withOculus": completeProfileBody.withOculus });
|
||||
}
|
||||
bodyLoader.setSource("UsernameCollisionBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": completeProfileBody.withSteam,
|
||||
"withOculus": completeProfileBody.withOculus });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ Item {
|
|||
property bool withOculus: withOculus
|
||||
property bool linkSteam: linkSteam
|
||||
property bool linkOculus: linkOculus
|
||||
property bool createOculus: createOculus
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
@ -73,8 +74,12 @@ Item {
|
|||
function init() {
|
||||
// For the process of logging in.
|
||||
loggingInText.wrapMode = Text.NoWrap;
|
||||
|
||||
if (loggingInBody.linkSteam) {
|
||||
if (loggingInBody.createOculus) {
|
||||
loggingInGlyph.text = hifi.glyphs.oculus;
|
||||
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;
|
||||
|
@ -243,6 +248,21 @@ Item {
|
|||
|
||||
Connections {
|
||||
target: loginDialog
|
||||
onHandleCreateCompleted: {
|
||||
console.log("Create Succeeded")
|
||||
if (loggingInBody.withOculus) {
|
||||
loggingInBody.createOculus = false;
|
||||
loggingInText.text = "Account created! Logging in to Oculus";
|
||||
loginDialog.loginThroughOculus();
|
||||
}
|
||||
}
|
||||
onHandleCreateFailed: {
|
||||
console.log("Create Failed: " + error);
|
||||
if (loggingInBody.withOculus) {
|
||||
bodyLoader.setSource("CompleteProfileBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": loggingInBody.withSteam,
|
||||
"withOculus": loggingInBody.withOculus, "errorString": error });
|
||||
}
|
||||
}
|
||||
onHandleLinkCompleted: {
|
||||
console.log("Link Succeeded");
|
||||
loggingInBody.linkSteam = false;
|
||||
|
|
|
@ -134,7 +134,7 @@ 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);
|
||||
DependencyManager::get<AccountManager>()->requestAccessTokenWithOculus(nonce, userID, oculusID);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ 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()) {
|
||||
if (nonce.isEmpty() || userID.isEmpty() || oculusID.isEmpty()) {
|
||||
emit handleLoginFailed();
|
||||
return;
|
||||
}
|
||||
|
@ -157,6 +157,7 @@ void LoginDialog::linkOculus() {
|
|||
QJsonObject payload;
|
||||
payload.insert("oculus_nonce", QJsonValue::fromVariant(QVariant(nonce)));
|
||||
payload.insert("oculus_user_id", QJsonValue::fromVariant(QVariant(userID)));
|
||||
payload.insert("oculus_id", QJsonValue::fromVariant(QVariant(oculusID)));
|
||||
|
||||
auto accountManager = DependencyManager::get<AccountManager>();
|
||||
accountManager->sendRequest(LINK_OCULUS_PATH, AccountManagerAuth::Required,
|
||||
|
@ -170,7 +171,7 @@ void LoginDialog::createAccountFromOculus(QString email, QString username, QStri
|
|||
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()) {
|
||||
if (nonce.isEmpty() || userID.isEmpty() || oculusID.isEmpty()) {
|
||||
emit handleLoginFailed();
|
||||
return;
|
||||
}
|
||||
|
@ -297,7 +298,6 @@ void LoginDialog::createFailed(QNetworkReply* reply) {
|
|||
QJsonParseError parseError;
|
||||
auto doc = QJsonDocument::fromJson(replyData, &parseError);
|
||||
if (parseError.error != QJsonParseError::NoError) {
|
||||
qDebug() << "Failed parsing error " << parseError.error;
|
||||
emit handleCreateFailed(reply->errorString());
|
||||
return;
|
||||
}
|
||||
|
@ -306,11 +306,19 @@ void LoginDialog::createFailed(QNetworkReply* reply) {
|
|||
auto error = data.value("error").toObject();
|
||||
auto identity = error.value("identity");
|
||||
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()) {
|
||||
emit handleCreateFailed("Oculus ID " + arr.at(0).toString() + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!user.isNull() && !user.isUndefined()) {
|
||||
QJsonArray arr = user.toArray();
|
||||
if (!arr.isEmpty()) {
|
||||
|
|
|
@ -586,7 +586,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) {
|
||||
void AccountManager::requestAccessTokenWithOculus(const QString& nonce, const QString& userID, const QString &oculusID) {
|
||||
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||
|
||||
QNetworkRequest request;
|
||||
|
@ -599,6 +599,7 @@ void AccountManager::requestAccessTokenWithOculus(const QString& nonce, const QS
|
|||
postData.append("grant_type=password&");
|
||||
postData.append("oculus_nonce=" + nonce + "&");
|
||||
postData.append("oculus_user_id=" + userID + "&");
|
||||
postData.append("oculus_id=" + oculusID + "&");
|
||||
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE);
|
||||
|
||||
request.setUrl(grantURL);
|
||||
|
|
|
@ -104,7 +104,7 @@ public:
|
|||
public slots:
|
||||
void requestAccessToken(const QString& login, const QString& password);
|
||||
void requestAccessTokenWithSteam(QByteArray authSessionTicket);
|
||||
void requestAccessTokenWithOculus(const QString& nonce, const QString& userID);
|
||||
void requestAccessTokenWithOculus(const QString& nonce, const QString& userID, const QString& oculusID);
|
||||
void requestAccessTokenWithAuthCode(const QString& authCode, const QString& clientId, const QString& clientSecret, const QString& redirectUri);
|
||||
void refreshAccessToken();
|
||||
|
||||
|
|
Loading…
Reference in a new issue