mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
linking oculus acct creation to spinner
This commit is contained in:
parent
f4d4220e58
commit
8e916ea41b
5 changed files with 53 additions and 31 deletions
|
@ -77,7 +77,7 @@ Item {
|
||||||
height: loginErrorMessageTextMetrics.height
|
height: loginErrorMessageTextMetrics.height
|
||||||
anchors {
|
anchors {
|
||||||
bottom: buttons.top;
|
bottom: buttons.top;
|
||||||
bottomMargin: hifi.dimensions.contentSpacing.y;
|
bottomMargin: 2 * hifi.dimensions.contentSpacing.y;
|
||||||
left: buttons.left;
|
left: buttons.left;
|
||||||
}
|
}
|
||||||
TextMetrics {
|
TextMetrics {
|
||||||
|
@ -102,10 +102,14 @@ Item {
|
||||||
loginErrorMessage.wrapMode = Text.WordWrap;
|
loginErrorMessage.wrapMode = Text.WordWrap;
|
||||||
loginErrorMessage.verticalAlignment = Text.AlignLeft;
|
loginErrorMessage.verticalAlignment = Text.AlignLeft;
|
||||||
loginErrorMessage.horizontalAlignment = 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) {
|
if (completeProfileBody.withOculus) {
|
||||||
errorContainer.anchors.bottom = fields.top;
|
errorContainer.anchors.bottom = fields.top;
|
||||||
|
errorContainer.anchors.bottomMargin = hifi.dimensions.contentSpacing.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,6 +157,8 @@ Item {
|
||||||
case Qt.Key_Return:
|
case Qt.Key_Return:
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
loginDialog.createAccountFromOculus(emailField.text, usernameField.text, passwordField.text);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,6 +206,8 @@ Item {
|
||||||
case Qt.Key_Return:
|
case Qt.Key_Return:
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
loginDialog.createAccountFromOculus(emailField.text, usernameField.text, passwordField.text);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,6 +345,8 @@ Item {
|
||||||
loginErrorMessage.visible = false;
|
loginErrorMessage.visible = false;
|
||||||
if (completeProfileBody.withOculus) {
|
if (completeProfileBody.withOculus) {
|
||||||
loginDialog.createAccountFromOculus(emailField.text, usernameField.text, passwordField.text);
|
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) {
|
} else if (completeProfileBody.withSteam) {
|
||||||
loginDialog.createAccountFromSteam();
|
loginDialog.createAccountFromSteam();
|
||||||
}
|
}
|
||||||
|
@ -452,10 +462,8 @@ Item {
|
||||||
Connections {
|
Connections {
|
||||||
target: loginDialog
|
target: loginDialog
|
||||||
onHandleCreateCompleted: {
|
onHandleCreateCompleted: {
|
||||||
console.log("Create Succeeded")
|
console.log("Create Succeeded");
|
||||||
if (completeProfileBody.withOculus) {
|
if (completeProfileBody.withSteam) {
|
||||||
loginDialog.loginThroughOculus();
|
|
||||||
} else if (completeProfileBody.withSteam) {
|
|
||||||
loginDialog.loginThroughSteam();
|
loginDialog.loginThroughSteam();
|
||||||
}
|
}
|
||||||
bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": completeProfileBody.withSteam, "linkSteam": false,
|
bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": completeProfileBody.withSteam, "linkSteam": false,
|
||||||
|
@ -463,23 +471,8 @@ Item {
|
||||||
}
|
}
|
||||||
onHandleCreateFailed: {
|
onHandleCreateFailed: {
|
||||||
console.log("Create Failed: " + error);
|
console.log("Create Failed: " + error);
|
||||||
if (completeProfileBody.withOculus) {
|
bodyLoader.setSource("UsernameCollisionBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": completeProfileBody.withSteam,
|
||||||
loginErrorMessage.visible = true;
|
"withOculus": completeProfileBody.withOculus });
|
||||||
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 });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ Item {
|
||||||
property bool withOculus: withOculus
|
property bool withOculus: withOculus
|
||||||
property bool linkSteam: linkSteam
|
property bool linkSteam: linkSteam
|
||||||
property bool linkOculus: linkOculus
|
property bool linkOculus: linkOculus
|
||||||
|
property bool createOculus: createOculus
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
id: d
|
id: d
|
||||||
|
@ -73,8 +74,12 @@ Item {
|
||||||
function init() {
|
function init() {
|
||||||
// For the process of logging in.
|
// For the process of logging in.
|
||||||
loggingInText.wrapMode = Text.NoWrap;
|
loggingInText.wrapMode = Text.NoWrap;
|
||||||
|
if (loggingInBody.createOculus) {
|
||||||
if (loggingInBody.linkSteam) {
|
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;
|
loggingInGlyph.visible = true;
|
||||||
loggingInText.text = "Linking to Steam";
|
loggingInText.text = "Linking to Steam";
|
||||||
loggingInText.x = loggingInHeader.width/2 - loggingInTextMetrics.width/2 + loggingInGlyphTextMetrics.width/2;
|
loggingInText.x = loggingInHeader.width/2 - loggingInTextMetrics.width/2 + loggingInGlyphTextMetrics.width/2;
|
||||||
|
@ -243,6 +248,21 @@ Item {
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: loginDialog
|
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: {
|
onHandleLinkCompleted: {
|
||||||
console.log("Link Succeeded");
|
console.log("Link Succeeded");
|
||||||
loggingInBody.linkSteam = false;
|
loggingInBody.linkSteam = false;
|
||||||
|
|
|
@ -134,7 +134,7 @@ void LoginDialog::loginThroughOculus() {
|
||||||
qDebug() << "Attempting to login through Oculus";
|
qDebug() << "Attempting to login through Oculus";
|
||||||
if (auto oculusPlatformPlugin = PluginManager::getInstance()->getOculusPlatformPlugin()) {
|
if (auto oculusPlatformPlugin = PluginManager::getInstance()->getOculusPlatformPlugin()) {
|
||||||
oculusPlatformPlugin->requestNonceAndUserID([this] (QString nonce, QString userID, QString oculusID) {
|
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";
|
qDebug() << "Attempting to link Oculus account";
|
||||||
if (auto oculusPlatformPlugin = PluginManager::getInstance()->getOculusPlatformPlugin()) {
|
if (auto oculusPlatformPlugin = PluginManager::getInstance()->getOculusPlatformPlugin()) {
|
||||||
oculusPlatformPlugin->requestNonceAndUserID([this] (QString nonce, QString userID, QString oculusID) {
|
oculusPlatformPlugin->requestNonceAndUserID([this] (QString nonce, QString userID, QString oculusID) {
|
||||||
if (nonce.isEmpty() || userID.isEmpty()) {
|
if (nonce.isEmpty() || userID.isEmpty() || oculusID.isEmpty()) {
|
||||||
emit handleLoginFailed();
|
emit handleLoginFailed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -157,6 +157,7 @@ void LoginDialog::linkOculus() {
|
||||||
QJsonObject payload;
|
QJsonObject payload;
|
||||||
payload.insert("oculus_nonce", QJsonValue::fromVariant(QVariant(nonce)));
|
payload.insert("oculus_nonce", QJsonValue::fromVariant(QVariant(nonce)));
|
||||||
payload.insert("oculus_user_id", QJsonValue::fromVariant(QVariant(userID)));
|
payload.insert("oculus_user_id", QJsonValue::fromVariant(QVariant(userID)));
|
||||||
|
payload.insert("oculus_id", QJsonValue::fromVariant(QVariant(oculusID)));
|
||||||
|
|
||||||
auto accountManager = DependencyManager::get<AccountManager>();
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
accountManager->sendRequest(LINK_OCULUS_PATH, AccountManagerAuth::Required,
|
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";
|
qDebug() << "Attempting to create account from Oculus info";
|
||||||
if (auto oculusPlatformPlugin = PluginManager::getInstance()->getOculusPlatformPlugin()) {
|
if (auto oculusPlatformPlugin = PluginManager::getInstance()->getOculusPlatformPlugin()) {
|
||||||
oculusPlatformPlugin->requestNonceAndUserID([this, email, username, password] (QString nonce, QString userID, QString oculusID) {
|
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();
|
emit handleLoginFailed();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -297,7 +298,6 @@ void LoginDialog::createFailed(QNetworkReply* reply) {
|
||||||
QJsonParseError parseError;
|
QJsonParseError parseError;
|
||||||
auto doc = QJsonDocument::fromJson(replyData, &parseError);
|
auto doc = QJsonDocument::fromJson(replyData, &parseError);
|
||||||
if (parseError.error != QJsonParseError::NoError) {
|
if (parseError.error != QJsonParseError::NoError) {
|
||||||
qDebug() << "Failed parsing error " << parseError.error;
|
|
||||||
emit handleCreateFailed(reply->errorString());
|
emit handleCreateFailed(reply->errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -306,11 +306,19 @@ void LoginDialog::createFailed(QNetworkReply* reply) {
|
||||||
auto error = data.value("error").toObject();
|
auto error = data.value("error").toObject();
|
||||||
auto identity = error.value("identity");
|
auto identity = error.value("identity");
|
||||||
auto user = error.value("username");
|
auto user = error.value("username");
|
||||||
|
auto uid = error.value("uid");
|
||||||
auto email = error.value("email");
|
auto email = error.value("email");
|
||||||
QString usernameError;
|
QString usernameError;
|
||||||
QString emailError;
|
QString emailError;
|
||||||
QString identityError;
|
QString identityError;
|
||||||
QString errorReply;
|
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()) {
|
if (!user.isNull() && !user.isUndefined()) {
|
||||||
QJsonArray arr = user.toArray();
|
QJsonArray arr = user.toArray();
|
||||||
if (!arr.isEmpty()) {
|
if (!arr.isEmpty()) {
|
||||||
|
|
|
@ -586,7 +586,7 @@ void AccountManager::requestAccessTokenWithSteam(QByteArray authSessionTicket) {
|
||||||
connect(requestReply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(requestAccessTokenError(QNetworkReply::NetworkError)));
|
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();
|
QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
|
||||||
|
|
||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
|
@ -599,6 +599,7 @@ void AccountManager::requestAccessTokenWithOculus(const QString& nonce, const QS
|
||||||
postData.append("grant_type=password&");
|
postData.append("grant_type=password&");
|
||||||
postData.append("oculus_nonce=" + nonce + "&");
|
postData.append("oculus_nonce=" + nonce + "&");
|
||||||
postData.append("oculus_user_id=" + userID + "&");
|
postData.append("oculus_user_id=" + userID + "&");
|
||||||
|
postData.append("oculus_id=" + oculusID + "&");
|
||||||
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE);
|
postData.append("scope=" + ACCOUNT_MANAGER_REQUESTED_SCOPE);
|
||||||
|
|
||||||
request.setUrl(grantURL);
|
request.setUrl(grantURL);
|
||||||
|
|
|
@ -104,7 +104,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void requestAccessToken(const QString& login, const QString& password);
|
void requestAccessToken(const QString& login, const QString& password);
|
||||||
void requestAccessTokenWithSteam(QByteArray authSessionTicket);
|
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 requestAccessTokenWithAuthCode(const QString& authCode, const QString& clientId, const QString& clientSecret, const QString& redirectUri);
|
||||||
void refreshAccessToken();
|
void refreshAccessToken();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue