File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ class wpn_acp_module
4444 /** @var array $errors */
4545 protected $ errors = [];
4646
47+ /** @var string Hide/replace private key with asterisks */
48+ public const MASKED_PRIVATE_KEY = '******** ' ;
49+
4750 /**
4851 * Main ACP module
4952 *
@@ -97,7 +100,7 @@ public function display_settings()
97100 $ this ->template ->assign_vars ([
98101 'S_WEBPUSH_ENABLE ' => $ this ->config ['wpn_webpush_enable ' ],
99102 'WEBPUSH_VAPID_PUBLIC ' => $ this ->config ['wpn_webpush_vapid_public ' ],
100- 'WEBPUSH_VAPID_PRIVATE ' => ! $ this ->config ['wpn_webpush_vapid_private ' ] ?: ' ******** ' , // Replace private key with asterixes
103+ 'WEBPUSH_VAPID_PRIVATE ' => $ this ->config ['wpn_webpush_vapid_private ' ] ? self :: MASKED_PRIVATE_KEY : '' ,
101104 'U_ACTION ' => $ this ->u_action ,
102105 ]);
103106 }
@@ -117,7 +120,7 @@ public function save_settings()
117120 ];
118121
119122 // Do not validate and update private key field if the content is ******** and the key was already set
120- if ($ config_array ['wpn_webpush_vapid_private ' ] == ' ******** ' && $ this ->config ['wpn_webpush_vapid_private ' ])
123+ if ($ config_array ['wpn_webpush_vapid_private ' ] === self :: MASKED_PRIVATE_KEY && $ this ->config ['wpn_webpush_vapid_private ' ])
121124 {
122125 unset($ display_settings ['wpn_webpush_vapid_private ' ], $ config_array ['wpn_webpush_vapid_private ' ]);
123126 }
Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ public function test_acp_module()
5757
5858 foreach ($ form_data as $ config_name => $ config_value )
5959 {
60- $ config_value = ($ config_name === 'config[wpn_webpush_vapid_private] ' ) ? ' ******** ' : $ config_value ;
60+ $ config_value = ($ config_name === 'config[wpn_webpush_vapid_private] ' ) ? \ phpbb \ webpushnotifications \ acp \wpn_acp_module:: MASKED_PRIVATE_KEY : $ config_value ;
6161 $ this ->assertEquals ($ config_value , $ crawler ->filter ('input[name=" ' . $ config_name . '"] ' )->attr ('value ' ));
6262 }
6363 }
You can’t perform that action at this time.
0 commit comments