| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hzWebhost::Login | (void) |
Declared in file: hzHttpClient.h
Defined in file : hzHttpClient.cpp
Function Logic:
Function body:
hzEcode hzWebhost::Login (void)
{
_hzfunc("hzWebhost::Login") ;
hzList<hzUrl>::Iter ias ;
hzList<hzPair>::Iter inv ;
hzVect<hzString> hdrs ;
ofstream os ;
hzDocument* pDoc ;
hzPair P ;
hzUrl url ;
hzString S ;
hzString etag ;
HttpRC hRet ;
bool bAuthpage = false ;
hzEcode rc = E_OK ;
threadLog("Starting Login Sequence\n") ;
if (m_Opflags & HZ_WEBSYNC_AUTH_BASIC)
{ threadLog("Basis Authentication. No login process required\n") ; return E_OK ; }
if (!(m_Opflags & (HZ_WEBSYNC_AUTH_POST | HZ_WEBSYNC_AUTH_GET)))
{
threadLog("No Authentication method\n") ;
if (!m_Authsteps.Count() && !m_Authform.Count())
{ threadLog("No Authentication steps or form submission. No login process required\n") ; return E_OK ; }
}
for (ias = m_Authsteps ; rc == E_OK && ias.Valid() ; ias++)
{
url = ias.Element() ;
if (url == m_Authpage)
bAuthpage = true ;
rc = HC.GetPage(hRet, url, etag) ;
if (rc != E_OK)
{ rc = E_NOTFOUND ; threadLog("Could not download %s\n", *url) ; }
}
if (rc != E_OK)
return rc ;
if (!bAuthpage && m_Authpage)
{
pDoc = Download(m_Authpage) ;
if (!pDoc)
{ threadLog("Could not download %s\n", *url) ; return E_NOTFOUND ; }
}
if (m_Authform.Count())
{
if (m_Repos)
{
S = m_Repos + "/login_form" ;
os.open(*S) ;
if (os.fail())
{ threadLog("Cannot write out header file %s\n", *S) ; return E_WRITEFAIL ; }
os << HC.m_Header ;
os << "\r\n\r\n" ;
os << HC.m_Content ;
os.close() ;
os.clear() ;
}
rc = HC.PostForm(hRet, m_Authpage, hdrs, m_Authform) ;
if (rc != E_OK)
{ threadLog("Could not post form to %s\n", *m_Authpage) ; return rc ; }
if (m_Repos)
{
S = m_Repos + "/login_response" ;
os.open(*S) ;
if (os.fail())
{ threadLog("Cannot write out header file %s\n", *S) ; return E_WRITEFAIL ; }
os << HC.m_Header ;
os << "\r\n\r\n" ;
os << HC.m_Content ;
os.close() ;
}
}
return rc ;
}