Added 'action' parameter to setUserDetail, and made it work when
the user is not logged in, so that it can be used for the recovery request.
This commit is contained in:
parent
6b7dcedc02
commit
cb959acb44
@ -66,15 +66,20 @@ namespace Online
|
||||
* to allow for shorter request creation code. It sets the name of
|
||||
* the script to invokce, token, and user id.
|
||||
* \param request The http request.
|
||||
* \param action If not empty, the action to be set.
|
||||
*/
|
||||
void CurrentUser::setUserDetails(HTTPRequest *request)
|
||||
void CurrentUser::setUserDetails(HTTPRequest *request,
|
||||
const std::string &action)
|
||||
{
|
||||
CurrentUser *cu = CurrentUser::get();
|
||||
assert(cu && cu->m_state == US_SIGNED_IN);
|
||||
assert(cu->m_profile);
|
||||
request->setServerURL("client-user.php");
|
||||
request->addParameter("token", cu->m_token);
|
||||
request->addParameter("userid", cu->m_profile->getID());
|
||||
|
||||
if (cu && cu->m_profile)
|
||||
request->addParameter("userid", cu->m_profile->getID());
|
||||
if(cu->m_state == US_SIGNED_IN)
|
||||
request->addParameter("token", cu->m_token);
|
||||
if (action.size() > 0)
|
||||
request->addParameter("action", action);
|
||||
} // setUserDetails
|
||||
|
||||
// ========================================================================
|
||||
|
@ -104,7 +104,8 @@ namespace Online
|
||||
/**Singleton */
|
||||
static CurrentUser * get();
|
||||
static void deallocate();
|
||||
static void setUserDetails(HTTPRequest *request);
|
||||
static void setUserDetails(HTTPRequest *request,
|
||||
const std::string &action);
|
||||
|
||||
void requestSavedSession();
|
||||
SignInRequest * requestSignIn( const irr::core::stringw &username,
|
||||
|
@ -154,8 +154,7 @@ void OnlineProfile::fetchAchievements()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
AchievementsRequest * request = new AchievementsRequest();
|
||||
CurrentUser::setUserDetails(request);
|
||||
request->addParameter("action", "get-achievements");
|
||||
CurrentUser::setUserDetails(request, "get-achievements");
|
||||
request->addParameter("visitingid", m_id);
|
||||
RequestManager::get()->addRequest(request);
|
||||
} // fetchAchievements
|
||||
@ -207,8 +206,7 @@ void OnlineProfile::fetchFriends()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
FriendsListRequest * request = new FriendsListRequest();
|
||||
CurrentUser::setUserDetails(request);
|
||||
request->addParameter("action", "get-friends-list");
|
||||
CurrentUser::setUserDetails(request, "get-friends-list");
|
||||
request->addParameter("visitingid", m_id);
|
||||
RequestManager::get()->addRequest(request);
|
||||
} // fetchFriends
|
||||
|
@ -138,8 +138,7 @@ void CreateServerScreen::serverCreationRequest()
|
||||
{
|
||||
|
||||
m_server_creation_request = new ServerCreationRequest();
|
||||
CurrentUser::setUserDetails(m_server_creation_request);
|
||||
m_server_creation_request->addParameter("action", "create_server");
|
||||
CurrentUser::setUserDetails(m_server_creation_request,"create_server");
|
||||
m_server_creation_request->addParameter("name", name);
|
||||
m_server_creation_request->addParameter("max_players", max_players);
|
||||
m_server_creation_request->queue();
|
||||
|
@ -110,9 +110,7 @@ void ChangePasswordDialog::changePassword(const stringw ¤t_password,
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
ChangePasswordRequest * request = new ChangePasswordRequest();
|
||||
CurrentUser::get()->setUserDetails(request);
|
||||
request->setServerURL("client-user.php");
|
||||
request->addParameter("action", "change_password");
|
||||
CurrentUser::setUserDetails(request, "change_password");
|
||||
request->addParameter("userid", CurrentUser::get()->getID());
|
||||
request->addParameter("current", current_password);
|
||||
// The server code expects two passwords (and verifies again that they
|
||||
|
@ -126,10 +126,10 @@ void RecoveryDialog::processInput()
|
||||
m_info_widget->setDefaultColor();
|
||||
m_options_widget->setDeactivated();
|
||||
m_recovery_request = new XMLRequest();
|
||||
m_recovery_request->setServerURL("client-user.php");
|
||||
m_recovery_request->addParameter("action", "recovery");
|
||||
// This function also works when the current user is not logged in
|
||||
CurrentUser::setUserDetails(m_recovery_request, "recovery");
|
||||
m_recovery_request->addParameter("username", username);
|
||||
m_recovery_request->addParameter("email", email);
|
||||
m_recovery_request->addParameter("email", email );
|
||||
m_recovery_request->queue();
|
||||
}
|
||||
} // processInput
|
||||
|
@ -169,8 +169,7 @@ void UserInfoDialog::sendFriendRequest()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
FriendRequest *request = new FriendRequest();
|
||||
CurrentUser::setUserDetails(request);
|
||||
request->addParameter("action", "friend-request");
|
||||
CurrentUser::setUserDetails(request, "friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
|
||||
@ -221,8 +220,7 @@ void UserInfoDialog::acceptFriendRequest()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
AcceptFriendRequest *request = new AcceptFriendRequest();
|
||||
CurrentUser::setUserDetails(request);
|
||||
request->addParameter("action", "accept-friend-request");
|
||||
CurrentUser::setUserDetails(request, "accept-friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
m_processing = true;
|
||||
@ -268,8 +266,7 @@ void UserInfoDialog::declineFriendRequest()
|
||||
}; // DeclineFriendRequest
|
||||
// ----------------------------------------------------------------
|
||||
DeclineFriendRequest *request = new DeclineFriendRequest();
|
||||
CurrentUser::setUserDetails(request);
|
||||
request->addParameter("action", "decline-friend-request");
|
||||
CurrentUser::setUserDetails(request, "decline-friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
|
||||
@ -316,8 +313,7 @@ void UserInfoDialog::removeExistingFriend()
|
||||
|
||||
int friend_id = m_profile->getID();
|
||||
RemoveFriendRequest * request = new RemoveFriendRequest(friend_id);
|
||||
CurrentUser::get()->setUserDetails(request);
|
||||
request->addParameter("action", "remove-friend");
|
||||
CurrentUser::setUserDetails(request, "remove-friend");
|
||||
request->addParameter("friendid", friend_id);
|
||||
request->queue();
|
||||
} // removeExistingFriend
|
||||
@ -361,8 +357,7 @@ void UserInfoDialog::removePendingFriend()
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
CancelFriendRequest * request = new CancelFriendRequest();
|
||||
CurrentUser::get()->setUserDetails(request);
|
||||
request->addParameter("action", "cancel-friend-request");
|
||||
CurrentUser::setUserDetails(request, "cancel-friend-request");
|
||||
request->addParameter("friendid", m_profile->getID());
|
||||
request->queue();
|
||||
} // removePendingFriend
|
||||
|
@ -60,8 +60,7 @@ VoteDialog::VoteDialog(const std::string & addon_id)
|
||||
|
||||
|
||||
m_fetch_vote_request = new XMLRequest();
|
||||
CurrentUser::get()->setUserDetails(m_fetch_vote_request);
|
||||
m_fetch_vote_request->addParameter("action", "get-addon-vote");
|
||||
CurrentUser::setUserDetails(m_fetch_vote_request, "get-addon-vote");
|
||||
m_fetch_vote_request->addParameter("addonid", addon_id.substr(6));
|
||||
m_fetch_vote_request->queue();
|
||||
|
||||
@ -120,8 +119,7 @@ void VoteDialog::sendVote()
|
||||
|
||||
|
||||
m_perform_vote_request = new SetAddonVoteRequest();
|
||||
CurrentUser::get()->setUserDetails(m_perform_vote_request);
|
||||
m_perform_vote_request->addParameter("action", "set-addon-vote");
|
||||
CurrentUser::setUserDetails(m_perform_vote_request, "set-addon-vote");
|
||||
m_perform_vote_request->addParameter("addonid", m_addon_id.substr(6));
|
||||
m_perform_vote_request->addParameter("rating", m_rating_widget->getRating());
|
||||
m_perform_vote_request->queue();
|
||||
|
@ -192,8 +192,7 @@ void OnlineUserSearch::search()
|
||||
if (m_search_string != "" && m_last_search_string != m_search_string)
|
||||
{
|
||||
m_search_request = new XMLRequest();
|
||||
CurrentUser::get()->setUserDetails(m_search_request);
|
||||
m_search_request->addParameter("action", "user-search");
|
||||
CurrentUser::setUserDetails(m_search_request, "user-search");
|
||||
m_search_request->addParameter("search-string", m_search_string);
|
||||
m_search_request->queue();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user