Skip to content

Commit 4954060

Browse files
committed
After review 0
1 parent c8b3c50 commit 4954060

File tree

6 files changed

+46
-19
lines changed

6 files changed

+46
-19
lines changed

assets/vue/components/subscribers/SubscriberDirectory.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ import SubscriberFilters from './SubscriberFilters.vue'
9191
import SubscriberTable from './SubscriberTable.vue'
9292
import SubscriberModal from './SubscriberModal.vue'
9393
import ImportResult from './ImportResult.vue'
94-
import { inject, ref, onMounted, watch } from 'vue'
95-
import { subscriberFilters } from './subscriberFilters'
96-
import { subscribersClient } from '../../api'
94+
import {inject, onMounted, ref} from 'vue'
95+
import {subscriberFilters} from './subscriberFilters'
96+
import {subscribersClient} from '../../api'
9797
9898
const initialSubscribers = inject('subscribers', [])
9999
const initialPagination = inject('pagination', {
@@ -275,12 +275,11 @@ const handleFileChange = async (event) => {
275275
276276
isImporting.value = true
277277
try {
278-
const result = await subscribersClient.importSubscribers({
278+
importResult.value = await subscribersClient.importSubscribers({
279279
file,
280280
listId: 0,
281281
updateExisting: true
282282
})
283-
importResult.value = result
284283
isImportResultOpen.value = true
285284
fetchSubscribers()
286285
} catch (error) {

assets/vue/components/subscribers/SubscriberModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<div class="mt-3 text-center sm:mt-0 sm:ml-4 sm:text-left w-full">
1111
<div class="flex justify-between items-center">
1212
<h3 class="text-lg leading-6 font-medium text-slate-900" id="modal-title">
13-
Subscriber Details ID: {{ subscriber.id }}
13+
Subscriber Details ID: {{ subscriber.id ?? '' }}
1414
</h3>
1515
<button type="button" class="text-slate-400 hover:text-slate-500" @click="close">
1616
<BaseIcon name="close" class="w-5 h-5" />

src/Controller/AuthController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function login(Request $request): Response
4646
try {
4747
$authData = $this->authClient->login($username, $password);
4848
$request->getSession()->set('auth_token', $authData['key']);
49-
$request->getSession()->set('auth_expiry_date', $authData['key']);
49+
$request->getSession()->set('auth_expiry_date', $authData['expiry_date']);
5050
$request->getSession()->set('auth_id', (int) $authData['id']);
5151

5252
return $this->redirectToRoute('home');

src/EventSubscriber/AuthGateSubscriber.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818
*/
1919
class AuthGateSubscriber implements EventSubscriberInterface
2020
{
21+
private const ALLOW_LIST = [
22+
'/api/v2',
23+
'/build/',
24+
'/assets/',
25+
'/css/',
26+
'/js/',
27+
'/images/',
28+
'/img/',
29+
'/favicon',
30+
'/robots.txt',
31+
];
32+
2133
public function __construct(private readonly UrlGeneratorInterface $urlGenerator)
2234
{
2335
}
@@ -63,7 +75,7 @@ private function isPublicPath(Request $request): bool
6375
}
6476

6577
// Allow static assets commonly served under these prefixes
66-
foreach (['/build/', '/assets/', '/css/', '/js/', '/images/', '/img/', '/favicon', '/robots.txt'] as $prefix) {
78+
foreach (self::ALLOW_LIST as $prefix) {
6779
if (str_starts_with($path, $prefix)) {
6880
return true;
6981
}

tests/System/ApplicationBundle/PhpListApplicationBundleTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function tearDown(): void
3535
public function testHomepageReturnsSuccess(): void
3636
{
3737
$this->startSymfonyServer();
38-
$response = $this->httpClient->get('/api/v2', [
38+
$response = $this->httpClient->get('/', [
3939
'base_uri' => $this->getBaseUrl(),
4040
]);
4141

tests/Unit/Controller/AuthControllerTest.php

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use PhpList\RestApiClient\Entity\Administrator;
88
use PhpList\WebFrontend\Controller\AuthController;
99
use PhpList\RestApiClient\Endpoint\AuthClient;
10+
use PHPUnit\Framework\Assert;
1011
use PHPUnit\Framework\MockObject\MockObject;
1112
use PHPUnit\Framework\TestCase;
1213
use RuntimeException;
@@ -107,13 +108,21 @@ public function testLoginWithPostRequestSuccess(): void
107108
['login_error', false]
108109
]);
109110

111+
$expected = [
112+
['auth_token', 'test-token'],
113+
['auth_expiry_date', '2026-03-18T14:15:38+04:00'],
114+
['auth_id', 1],
115+
];
116+
117+
$index = 0;
118+
110119
$session->expects($this->exactly(3))
111120
->method('set')
112-
->withConsecutive(
113-
['auth_token', 'test-token'],
114-
['auth_expiry_date', 'test-token'],
115-
['auth_id', 1]
116-
);
121+
->willReturnCallback(function ($key, $value) use (&$expected, &$index) {
122+
Assert::assertSame($expected[$index][0], $key);
123+
Assert::assertSame($expected[$index][1], $value);
124+
$index++;
125+
});
117126

118127
$request = Request::create('/login', 'POST', [
119128
'username' => 'testuser',
@@ -123,7 +132,7 @@ public function testLoginWithPostRequestSuccess(): void
123132

124133
$this->authClient->method('login')
125134
->with('testuser', 'testpass')
126-
->willReturn(['key' => 'test-token', 'id' => 1]);
135+
->willReturn(['key' => 'test-token', 'id' => 1, 'expiry_date' => '2026-03-18T14:15:38+04:00']);
127136

128137
$response = $this->controller->login($request);
129138

@@ -181,12 +190,19 @@ public function testLoginWithExistingSession(): void
181190
public function testLogout(): void
182191
{
183192
$session = $this->createMock(SessionInterface::class);
193+
$expected = [
194+
['auth_token'],
195+
['auth_id'],
196+
];
197+
198+
$index = 0;
199+
184200
$session->expects($this->exactly(2))
185201
->method('remove')
186-
->withConsecutive(
187-
['auth_token'],
188-
['auth_id']
189-
);
202+
->willReturnCallback(function ($key) use (&$expected, &$index) {
203+
Assert::assertSame($expected[$index][0], $key);
204+
$index++;
205+
});
190206

191207
$request = $this->createMock(Request::class);
192208
$request->method('getSession')

0 commit comments

Comments
 (0)