mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:00:41 +02:00
expose access token from AccountManager
This commit is contained in:
parent
709bcdb148
commit
4936fb3857
7 changed files with 28 additions and 12 deletions
|
@ -3071,7 +3071,7 @@ void Application::updateWindowTitle(){
|
||||||
QString buildVersion = " (build " + applicationVersion() + ")";
|
QString buildVersion = " (build " + applicationVersion() + ")";
|
||||||
NodeList* nodeList = NodeList::getInstance();
|
NodeList* nodeList = NodeList::getInstance();
|
||||||
|
|
||||||
QString username = AccountManager::getInstance().getUsername();
|
QString username = AccountManager::getInstance().getAccountInfo().getUsername();
|
||||||
QString title = QString() + (!username.isEmpty() ? username + " " : QString()) + nodeList->getSessionUUID().toString()
|
QString title = QString() + (!username.isEmpty() ? username + " " : QString()) + nodeList->getSessionUUID().toString()
|
||||||
+ " @ " + nodeList->getDomainHandler().getHostname() + buildVersion;
|
+ " @ " + nodeList->getDomainHandler().getHostname() + buildVersion;
|
||||||
qDebug("Application title set to: %s", title.toStdString().c_str());
|
qDebug("Application title set to: %s", title.toStdString().c_str());
|
||||||
|
|
|
@ -1119,7 +1119,7 @@ void Menu::toggleLoginMenuItem() {
|
||||||
|
|
||||||
if (accountManager.isLoggedIn()) {
|
if (accountManager.isLoggedIn()) {
|
||||||
// change the menu item to logout
|
// change the menu item to logout
|
||||||
_loginAction->setText("Logout " + accountManager.getUsername());
|
_loginAction->setText("Logout " + accountManager.getAccountInfo().getUsername());
|
||||||
connect(_loginAction, &QAction::triggered, &accountManager, &AccountManager::logout);
|
connect(_loginAction, &QAction::triggered, &accountManager, &AccountManager::logout);
|
||||||
} else {
|
} else {
|
||||||
// change the menu item to login
|
// change the menu item to login
|
||||||
|
|
|
@ -34,12 +34,13 @@ XmppClient& XmppClient::getInstance() {
|
||||||
|
|
||||||
void XmppClient::xmppConnected() {
|
void XmppClient::xmppConnected() {
|
||||||
_publicChatRoom = _xmppMUCManager.addRoom(DEFAULT_CHAT_ROOM);
|
_publicChatRoom = _xmppMUCManager.addRoom(DEFAULT_CHAT_ROOM);
|
||||||
_publicChatRoom->setNickName(AccountManager::getInstance().getUsername());
|
_publicChatRoom->setNickName(AccountManager::getInstance().getAccountInfo().getUsername());
|
||||||
_publicChatRoom->join();
|
_publicChatRoom->join();
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmppClient::xmppError(QXmppClient::Error error) {
|
void XmppClient::xmppError(QXmppClient::Error error) {
|
||||||
qDebug() << "Error connnecting to XMPP for user " << AccountManager::getInstance().getUsername() << ": " << error;
|
qDebug() << "Error connnecting to XMPP for user "
|
||||||
|
<< AccountManager::getInstance().getAccountInfo().getUsername() << ": " << error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XmppClient::connectToServer() {
|
void XmppClient::connectToServer() {
|
||||||
|
@ -50,8 +51,8 @@ void XmppClient::connectToServer() {
|
||||||
connect(&_xmppClient, SIGNAL(error(QXmppClient::Error)), this, SLOT(xmppError(QXmppClient::Error)));
|
connect(&_xmppClient, SIGNAL(error(QXmppClient::Error)), this, SLOT(xmppError(QXmppClient::Error)));
|
||||||
}
|
}
|
||||||
AccountManager& accountManager = AccountManager::getInstance();
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
QString user = accountManager.getUsername();
|
QString user = accountManager.getAccountInfo().getUsername();
|
||||||
const QString& password = accountManager.getXMPPPassword();
|
const QString& password = accountManager.getAccountInfo().getXMPPPassword();
|
||||||
_xmppClient.connectToServer(user + "@" + DEFAULT_XMPP_SERVER, password);
|
_xmppClient.connectToServer(user + "@" + DEFAULT_XMPP_SERVER, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -254,7 +254,7 @@ void ChatWindow::messageReceived(const QXmppMessage& message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update background if this is a message from the current user
|
// Update background if this is a message from the current user
|
||||||
bool fromSelf = getParticipantName(message.from()) == AccountManager::getInstance().getUsername();
|
bool fromSelf = getParticipantName(message.from()) == AccountManager::getInstance().getAccountInfo().getUsername();
|
||||||
|
|
||||||
// Create message area
|
// Create message area
|
||||||
ChatMessageArea* messageArea = new ChatMessageArea(true);
|
ChatMessageArea* messageArea = new ChatMessageArea(true);
|
||||||
|
|
|
@ -63,7 +63,24 @@ void OAuthWebViewHandler::displayWebviewForAuthorizationURL(const QUrl& authoriz
|
||||||
_activeWebView->setAttribute(Qt::WA_DeleteOnClose);
|
_activeWebView->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
|
||||||
qDebug() << "Displaying QWebView for OAuth authorization at" << authorizationURL.toString();
|
qDebug() << "Displaying QWebView for OAuth authorization at" << authorizationURL.toString();
|
||||||
_activeWebView->load(authorizationURL);
|
|
||||||
|
AccountManager& accountManager = AccountManager::getInstance();
|
||||||
|
|
||||||
|
QUrl codedAuthorizationURL = authorizationURL;
|
||||||
|
|
||||||
|
// check if we have an access token for this host - if so we can bypass login by adding it to the URL
|
||||||
|
if (accountManager.getAuthURL().host() == authorizationURL.host()
|
||||||
|
&& accountManager.hasValidAccessToken()) {
|
||||||
|
|
||||||
|
const QString ACCESS_TOKEN_QUERY_STRING_KEY = "access_token";
|
||||||
|
|
||||||
|
QUrlQuery authQuery(codedAuthorizationURL);
|
||||||
|
authQuery.addQueryItem(ACCESS_TOKEN_QUERY_STRING_KEY, accountManager.getAccountInfo().getAccessToken().token);
|
||||||
|
|
||||||
|
codedAuthorizationURL.setQuery(authQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
_activeWebView->load(codedAuthorizationURL);
|
||||||
_activeWebView->show();
|
_activeWebView->show();
|
||||||
|
|
||||||
connect(_activeWebView->page()->networkAccessManager(), &QNetworkAccessManager::sslErrors,
|
connect(_activeWebView->page()->networkAccessManager(), &QNetworkAccessManager::sslErrors,
|
||||||
|
|
|
@ -86,7 +86,7 @@ void Snapshot::saveSnapshot(QGLWidget* widget, Avatar* avatar) {
|
||||||
// replace decimal . with '-'
|
// replace decimal . with '-'
|
||||||
formattedLocation.replace('.', '-');
|
formattedLocation.replace('.', '-');
|
||||||
|
|
||||||
QString username = AccountManager::getInstance().getUsername();
|
QString username = AccountManager::getInstance().getAccountInfo().getUsername();
|
||||||
// normalize username, replace all non alphanumeric with '-'
|
// normalize username, replace all non alphanumeric with '-'
|
||||||
username.replace(QRegExp("[^A-Za-z0-9_]"), "-");
|
username.replace(QRegExp("[^A-Za-z0-9_]"), "-");
|
||||||
|
|
||||||
|
|
|
@ -55,9 +55,7 @@ public:
|
||||||
|
|
||||||
void requestAccessToken(const QString& login, const QString& password);
|
void requestAccessToken(const QString& login, const QString& password);
|
||||||
|
|
||||||
QString getUsername() const { return _accountInfo.getUsername(); }
|
const DataServerAccountInfo& getAccountInfo() const { return _accountInfo; }
|
||||||
|
|
||||||
const QString& getXMPPPassword() const { return _accountInfo.getXMPPPassword(); }
|
|
||||||
|
|
||||||
void destroy() { delete _networkAccessManager; }
|
void destroy() { delete _networkAccessManager; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue