Fix when using Facebook Menu to log out in a FeedDialog (the www.facebook.com/logout.php is called but the token wasn't deleted).

This commit is contained in:
AlanGusLive 2016-01-16 11:43:33 +01:00
Родитель 4d0fdf903a
Коммит 4bc7b1ebef
3 изменённых файлов: 56 добавлений и 17 удалений

Просмотреть файл

@ -137,16 +137,24 @@ void Dialogs::Feed_Click(
)
{
FBSession^ s = FBSession::ActiveSession;
PropertySet^ params = ref new PropertySet();
params->Insert(L"caption", L"I love Brussels Sprouts!");
params->Insert(L"link", L"https://en.wikipedia.org/wiki/Brussels_sprout");
params->Insert(L"description", L"Om Nom Nom!");
create_task(s->ShowFeedDialogAsync(params))
.then([=](FBResult^ DialogResponse)
{
OutputDebugString(L"Showed 'Feed' dialog.\n");
});
if (s->AccessTokenData == nullptr)
{
OutputDebugString(L"User is not logged (access token was deleted).\n");
}
else
{
PropertySet^ params = ref new PropertySet();
params->Insert(L"caption", L"I love Brussels Sprouts!");
params->Insert(L"link", L"https://en.wikipedia.org/wiki/Brussels_sprout");
params->Insert(L"description", L"Om Nom Nom!");
create_task(s->ShowFeedDialogAsync(params))
.then([=](FBResult^ DialogResponse)
{
OutputDebugString(L"Showed 'Feed' dialog.\n");
});
}
}
@ -156,14 +164,22 @@ void Dialogs::AppRequests_Click(
)
{
FBSession^ s = FBSession::ActiveSession;
PropertySet^ params = ref new PropertySet();
params->Insert(L"title", L"I love Brussels Sprouts!");
params->Insert(L"message", L"Om Nom Nom!");
if (s->AccessTokenData == nullptr)
{
OutputDebugString(L"User is not logged (access token was deleted).\n");
}
else
{
PropertySet^ params = ref new PropertySet();
create_task(s->ShowRequestsDialogAsync(params))
.then([=](FBResult^ DialogResponse)
{
OutputDebugString(L"Showed 'Requests' dialog.\n");
});
params->Insert(L"title", L"I love Brussels Sprouts!");
params->Insert(L"message", L"Om Nom Nom!");
create_task(s->ShowRequestsDialogAsync(params))
.then([=](FBResult^ DialogResponse)
{
OutputDebugString(L"Showed 'Requests' dialog.\n");
});
}
}

Просмотреть файл

@ -55,6 +55,7 @@ using namespace std;
#define FACEBOOK_DESKTOP_SERVER_NAME L"www"
#define FACEBOOK_MOBILE_SERVER_NAME L"m"
#define FACEBOOK_LOGIN_SUCCESS_PATH L"/connect/login_success.html"
#define FACEBOOK_LOGOUT_PATH L"/logout.php"
#define FACEBOOK_DIALOG_CLOSE_PATH L"/dialog/close"
const wchar_t* ErrorObjectJson = L"{\"error\": {\"message\": " \
@ -399,6 +400,13 @@ bool FacebookDialog::IsLoginSuccessRedirect(
return (String::CompareOrdinal(Response->Path, FACEBOOK_LOGIN_SUCCESS_PATH) == 0);
}
bool FacebookDialog::IsLogoutRedirect(
Uri^ Response
)
{
return (String::CompareOrdinal(Response->Path, FACEBOOK_LOGOUT_PATH) == 0);
}
bool FacebookDialog::IsDialogCloseRedirect(
Uri^ Response
)
@ -463,6 +471,17 @@ void FacebookDialog::dialogWebView_FeedNavStarting(
_dialogResponse = ref new FBResult(err);
}
}
else if (IsLogoutRedirect(e->Uri))
{
UninitDialog();
DebugPrintLine(L"Feed response is " + e->Uri->DisplayUri);
FBSession^ sess = FBSession::ActiveSession;
sess->LogoutAsync();
FBError^ err = FBError::FromJson(ref new String(ErrorObjectJson));
_dialogResponse = ref new FBResult(err);
}
else if (IsDialogCloseRedirect(e->Uri))
{
UninitDialog();

Просмотреть файл

@ -128,6 +128,10 @@ namespace winsdkfb
Windows::Foundation::Uri^ Response
);
bool IsLogoutRedirect(
Windows::Foundation::Uri^ Response
);
bool IsDialogCloseRedirect(
Windows::Foundation::Uri^ Response
);