File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33namespace OWC \PrefillGravityForms \Controllers ;
44
5+ use Exception ;
6+ use function OWC \PrefillGravityForms \Foundation \Helpers \decrypt ;
57use function OWC \PrefillGravityForms \Foundation \Helpers \view ;
6- use function Yard \DigiD \Foundation \Helpers \decrypt ;
78use function Yard \DigiD \Foundation \Helpers \resolve ;
89use OWC \PrefillGravityForms \Foundation \TeamsLogger ;
910use OWC \PrefillGravityForms \GravityForms \GravityFormsSettings ;
@@ -33,31 +34,15 @@ public function resolveTeams(): TeamsLogger
3334 }
3435 }
3536
36- /**
37- * Validate if form has a DigiD field.
38- * If so return the decrypted BSN number.
39- */
40- protected function getBSN (array $ form ): string
37+ protected function getBSN (): string
4138 {
42- $ bsn = '' ;
43-
44- foreach ($ form ['fields ' ] as $ field ) {
45- if ($ field ->type !== 'digid ' ) {
46- continue ;
47- }
48-
49- $ resolvedBSN = resolve ('session ' )->getSegment ('digid ' )->get ('bsn ' );
50-
51- if (empty ($ resolvedBSN )) {
52- continue ;
53- }
54-
55- $ bsn = decrypt ($ resolvedBSN );
56-
57- break ;
39+ try {
40+ $ bsn = resolve ('session ' )->getSegment ('digid ' )->get ('bsn ' );
41+ } catch (Exception $ e ) {
42+ $ bsn = '' ;
5843 }
5944
60- return $ bsn ;
45+ return is_string ( $ bsn) && ! empty ( $ bsn ) ? decrypt ( $ bsn ) : '' ;
6146 }
6247
6348 /**
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ class EnableUController extends BaseController
66{
77 public function handle (array $ form )
88 {
9- $ bsn = $ this ->getBSN ($ form );
9+ $ bsn = $ this ->getBSN ();
1010
1111 if (empty ($ bsn )) {
1212 return $ form ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ class OpenZaakController extends BaseController
66{
77 public function handle (array $ form )
88 {
9- $ bsn = $ this ->getBSN ($ form );
9+ $ bsn = $ this ->getBSN ();
1010
1111 if (empty ($ bsn )) {
1212 return $ form ;
Original file line number Diff line number Diff line change 44
55class Cryptor
66{
7- /** @var string */
8- protected $ method = ' aes-128-ctr ' ; // default cipher method if none supplied
7+ protected string $ method = ' aes-128-ctr ' ; // default cipher method if none supplied
8+ private string $ key ;
99
10- /** @var string */
11- private $ key ;
12-
13- /**
14- * @param boolean $method
15- */
16- public function __construct ($ method = false )
10+ public function __construct (bool $ method = false )
1711 {
1812 $ key = \AUTH_KEY ?? php_uname ();
1913 if (ctype_print ($ key )) {
Original file line number Diff line number Diff line change @@ -52,13 +52,7 @@ function decrypt($string): string
5252 return $ decrypted ?: '' ;
5353}
5454
55- /**
56- * @param string $setting
57- * @param string $default
58- *
59- * @return string
60- */
61- function config (string $ setting , $ default = '' ): ?string
55+ function config (string $ setting , $ default = '' )
6256{
6357 return resolve ('config ' )->get ($ setting , $ default );
6458}
You can’t perform that action at this time.
0 commit comments