[editor] Review fixes for reset password

This commit is contained in:
Ilya Zverev 2016-01-23 13:00:50 +03:00 committed by Sergey Yershov
parent ef7a46792d
commit 50b59fdd62
3 changed files with 5 additions and 6 deletions

View file

@ -59,8 +59,8 @@ UNIT_TEST(OSM_Auth_Facebook)
UNIT_TEST(OSM_Auth_ForgotPassword)
{
OsmOAuth auth = OsmOAuth::IZServerAuth();
auto result = auth.RestorePassword(kIZForgotPasswordEmail);
auto result = auth.ResetPassword(kIZForgotPasswordEmail);
TEST_EQUAL(result, OsmOAuth::AuthResult::OK, ("Correct email"));
result = auth.RestorePassword("incorrect@ema.il");
result = auth.ResetPassword("not@registered.email");
TEST_EQUAL(result, OsmOAuth::AuthResult::NoEmail, ("Incorrect email"));
}

View file

@ -296,7 +296,7 @@ OsmOAuth::TUrlKeySecret OsmOAuth::GetGoogleOAuthURL() const
return TUrlKeySecret(url, requestToken);
}
OsmOAuth::AuthResult OsmOAuth::RestorePassword(string const & email) const
OsmOAuth::AuthResult OsmOAuth::ResetPassword(string const & email) const
{
string const kForgotPasswordUrlPart = "/user/forgot-password";
@ -316,8 +316,7 @@ OsmOAuth::AuthResult OsmOAuth::RestorePassword(string const & email) const
if (!request.RunHTTPRequest())
return AuthResult::NetworkError;
string const content = request.server_response();
return content.find("<div class=\"flash notice\">") == string::npos ? AuthResult::NoEmail : AuthResult::OK;
return request.was_redirected() && request.url_received().find(m_baseUrl) != string::npos ? AuthResult::OK : AuthResult::NoEmail;
}
OsmOAuth::Response OsmOAuth::Request(TKeySecret const & keySecret, string const & method, string const & httpMethod, string const & body) const

View file

@ -66,7 +66,7 @@ public:
AuthResult AuthorizePassword(string const & login, string const & password, TKeySecret & outKeySecret) const;
AuthResult AuthorizeFacebook(string const & facebookToken, TKeySecret & outKeySecret) const;
AuthResult AuthorizeGoogle(string const & googleToken, TKeySecret & outKeySecret) const;
AuthResult RestorePassword(string const & email) const;
AuthResult ResetPassword(string const & email) const;
/// @param[method] The API method, must start with a forward slash.
Response Request(TKeySecret const & keySecret, string const & method, string const & httpMethod = "GET", string const & body = "") const;
//@}