Prevent unauthorized access to chat history

This commit is contained in:
Fedor A. Fetisov 2017-07-06 16:00:06 +03:00
parent 38e53aaa6a
commit a617eebeec

View File

@ -50,9 +50,13 @@ class MailController extends AbstractController
$thread_id = $request->attributes->get('thread_id');
$token = $request->attributes->get('token');
// We have to check that the thread is owned by the user.
$is_own_thread = isset($_SESSION[SESSION_PREFIX . 'own_threads'])
&& in_array($thread_id, $_SESSION[SESSION_PREFIX . 'own_threads']);
// Try to load the thread
$thread = Thread::load($thread_id, $token);
if (!$thread) {
if (!$thread || !$is_own_thread) {
throw new NotFoundException('The thread is not found.');
}
@ -86,9 +90,13 @@ class MailController extends AbstractController
$thread_id = $request->attributes->get('thread_id');
$token = $request->attributes->get('token');
// We have to check that the thread is owned by the user.
$is_own_thread = isset($_SESSION[SESSION_PREFIX . 'own_threads'])
&& in_array($thread_id, $_SESSION[SESSION_PREFIX . 'own_threads']);
// Try to load the thread
$thread = Thread::load($thread_id, $token);
if (!$thread) {
if (!$thread || !$is_own_thread) {
throw new NotFoundException('The thread is not found.');
}