4
4
5
5
namespace OliverKlee \Seminars \Controller ;
6
6
7
+ use OliverKlee \FeUserExtraFields \Domain \Model \FrontendUser ;
8
+ use OliverKlee \Seminars \Domain \Model \Registration \Registration ;
7
9
use OliverKlee \Seminars \Domain \Repository \Registration \RegistrationRepository ;
8
10
use Psr \Http \Message \ResponseInterface ;
9
11
use TYPO3 \CMS \Core \Context \Context ;
12
+ use TYPO3 \CMS \Extbase \Annotation \IgnoreValidation ;
10
13
use TYPO3 \CMS \Extbase \Http \ForwardResponse ;
11
14
use TYPO3 \CMS \Extbase \Mvc \Controller \ActionController ;
12
15
@@ -27,17 +30,36 @@ public function __construct(Context $context, RegistrationRepository $registrati
27
30
28
31
public function indexAction (): ResponseInterface
29
32
{
30
- $ userUid = $ this ->getLoggedInUserUid ();
31
- if ($ userUid <= 0 ) {
33
+ $ loggedInUserUid = $ this ->getLoggedInUserUid ();
34
+ if ($ loggedInUserUid <= 0 ) {
32
35
return new ForwardResponse ('notLoggedIn ' );
33
36
}
34
37
35
- $ registrations = $ this ->registrationRepository ->findActiveRegistrationsByUser ($ userUid );
38
+ $ registrations = $ this ->registrationRepository ->findActiveRegistrationsByUser ($ loggedInUserUid );
36
39
$ this ->view ->assign ('registrations ' , $ registrations );
37
40
38
41
return $ this ->htmlResponse ();
39
42
}
40
43
44
+ /**
45
+ * @IgnoreValidation("registration")
46
+ */
47
+ public function showAction (Registration $ registration ): ResponseInterface
48
+ {
49
+ $ loggedInUserUid = $ this ->getLoggedInUserUid ();
50
+ if ($ loggedInUserUid <= 0 ) {
51
+ return new ForwardResponse ('notLoggedIn ' );
52
+ }
53
+ $ registrationUser = $ registration ->getUser ();
54
+ if (!($ registrationUser instanceof FrontendUser) || $ registrationUser ->getUid () !== $ loggedInUserUid ) {
55
+ return new ForwardResponse ('notFound ' );
56
+ }
57
+
58
+ $ this ->view ->assign ('registration ' , $ registration );
59
+
60
+ return $ this ->htmlResponse ();
61
+ }
62
+
41
63
/**
42
64
* @return int<0, max>
43
65
*/
@@ -54,4 +76,9 @@ public function notLoggedInAction(): ResponseInterface
54
76
{
55
77
return $ this ->htmlResponse ()->withStatus (403 );
56
78
}
79
+
80
+ public function notFoundAction (): ResponseInterface
81
+ {
82
+ return $ this ->htmlResponse ()->withStatus (404 );
83
+ }
57
84
}
0 commit comments