Exemplo n.º 1
0
void WebCoreClass::logIn(const char* user, const char* pass, TiXmlDocument &doc)
{
	if (m_bUserAuth)
		throw gcException(ERR_ALREADYLOGGEDIN);

	PostMap post;

	post["username"] = user;
	post["password"] = pass;

	TiXmlNode* uNode = loginToServer(getLoginUrl(), "memberlogin", post, doc);
	TiXmlElement *memNode = uNode->FirstChildElement("member");
	
	if (!memNode)
		throw gcException(ERR_BADXML);

	const char* idStr =  memNode->Attribute("siteareaid");

	if (!idStr || atoi(idStr) < 0)
		throw gcException(ERR_BAD_PORU);

	m_uiUserId = atoi(idStr);

	TiXmlNode *cookieNode = memNode->FirstChild("cookies");
	if (cookieNode)
	{
		XML::GetChild("id", m_szIdCookie, cookieNode);
		XML::GetChild("session", m_szSessCookie, cookieNode);
	}

	m_bUserAuth = true;
}
Exemplo n.º 2
0
void VKApi::login() {
    if (isLoggedIn() || loginView) {
        return;
    }

    auto webView = new QWebView();
    webView->setAttribute(Qt::WA_DeleteOnClose, true);
    auto url = getLoginUrl();
    webView->load( url );

    connect(webView, SIGNAL(urlChanged(QUrl)), this, SLOT(loginUrlChanged(const QUrl&)));
    connect(webView, &QWebView::destroyed, [this](){
        this->loginView = 0;
    });
    webView->show();

    loginView = webView;

}