File tree 2 files changed +28
-4
lines changed
2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change 2
2
"name" : " passbolt/passbolt-selenium-api" ,
3
3
"description" : " Passbolt selenium testing helper endpoints" ,
4
4
"type" : " cakephp-plugin" ,
5
- "version" : " 3.1.2 " ,
5
+ "version" : " 3.2.0 " ,
6
6
"keywords" : [
7
7
" password" ,
8
8
" passbolt" ,
Original file line number Diff line number Diff line change @@ -66,10 +66,16 @@ public function showLastEmail($username)
66
66
throw new HttpException (__ ('The username does not exist. ' ));
67
67
}
68
68
$ EmailQueue = TableRegistry::getTableLocator ()->get ('EmailQueue.EmailQueue ' );
69
- $ email = $ EmailQueue ->find ('all ' )
69
+ $ emailQuery = $ EmailQueue ->find ('all ' )
70
70
->where (['email ' => $ username ])
71
- ->order (['created ' => 'DESC ' ])
72
- ->first ();
71
+ ->order (['created ' => 'DESC ' ]);
72
+
73
+ $ emailType = $ this ->getEmailType ();
74
+ if (!is_null ($ emailType )) {
75
+ $ emailQuery ->where (['template ' => $ emailType ]);
76
+ }
77
+
78
+ $ email = $ emailQuery ->first ();
73
79
if (empty ($ email )) {
74
80
throw new HttpException (__ ('No email was sent to this user. ' ));
75
81
}
@@ -85,4 +91,22 @@ public function showLastEmail($username)
85
91
->setTemplate ($ email ->template )
86
92
->setTemplatePath ("email/ $ format " );
87
93
}
94
+
95
+ /**
96
+ * Returns a validated `has-type` filter set in the query parameters of the request if any.
97
+ * @return string|null
98
+ */
99
+ private function getEmailType () {
100
+ $ filter = $ this ->request ->getQuery ('filter ' );
101
+ if (is_null ($ filter ) || !is_array ($ filter )) {
102
+ return null ;
103
+ }
104
+
105
+ $ hasType = $ filter ['has-type ' ];
106
+ if (empty ($ hasType ) || !is_string ($ hasType )) {
107
+ return null ;
108
+ }
109
+
110
+ return $ hasType ;
111
+ }
88
112
}
You can’t perform that action at this time.
0 commit comments