Opens a login page and extract a cookie and a secret token.
| 142 | |
| 143 | // Opens a login page and extract a cookie and a secret token. |
| 144 | OsmOAuth::SessionID OsmOAuth::FetchSessionId(string const & subUrl, string const & cookies) const |
| 145 | { |
| 146 | string const url = m_baseUrl + subUrl + (cookies.empty() ? "?cookie_test=true" : ""); |
| 147 | HttpClient request(url); |
| 148 | request.SetCookies(cookies); |
| 149 | if (!request.RunHttpRequest()) |
| 150 | MYTHROW(NetworkError, ("FetchSessionId Network error while connecting to", url)); |
| 151 | if (request.WasRedirected()) |
| 152 | MYTHROW(UnexpectedRedirect, ("FetchSessionId Unexpected redirected to", request.UrlReceived(), "from", url)); |
| 153 | if (request.ErrorCode() != HTTP::OK) |
| 154 | MYTHROW(FetchSessionIdError, (DebugPrint(request))); |
| 155 | |
| 156 | SessionID sid = {request.CombinedCookies(), FindAuthenticityToken("/login", request.ServerResponse())}; |
| 157 | if (sid.m_cookies.empty() || sid.m_authenticityToken.empty()) |
| 158 | MYTHROW(FetchSessionIdError, ("Cookies and/or token are empty for request", DebugPrint(request))); |
| 159 | return sid; |
| 160 | } |
| 161 | |
| 162 | void OsmOAuth::LogoutUser(SessionID const & sid) const |
| 163 | { |
nothing calls this directly
no test coverage detected