File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace APP \plugins \generic \dataverse \classes \migrations ;
4+
5+ use Illuminate \Database \Migrations \Migration ;
6+ use Illuminate \Support \Facades \DB ;
7+ use APP \plugins \generic \dataverse \classes \DataEncryption ;
8+
9+ class APITokenEncryptionMigration extends Migration
10+ {
11+ public function up (): void
12+ {
13+ $ encrypter = new DataEncryption ();
14+ if (!$ encrypter ->secretConfigExists ()) {
15+ return ;
16+ }
17+
18+ DB ::table ('plugin_settings ' )
19+ ->where ('plugin_name ' , 'dataverseplugin ' )
20+ ->where ('setting_name ' , 'apiToken ' )
21+ ->get (['context_id ' , 'setting_value ' ])
22+ ->each (function ($ row ) use ($ encrypter ) {
23+ if (empty ($ row ->setting_value ) || $ encrypter ->textIsEncrypted ($ row ->setting_value )) {
24+ return ;
25+ }
26+
27+ $ encryptedValue = $ encrypter ->encryptString ($ row ->setting_value );
28+ DB ::table ('plugin_settings ' )
29+ ->where ('plugin_name ' , 'dataverseplugin ' )
30+ ->where ('context_id ' , $ row ->context_id )
31+ ->where ('setting_name ' , 'apiToken ' )
32+ ->update (['setting_value ' => $ encryptedValue ]);
33+ });
34+ }
35+
36+ }
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <!DOCTYPE install SYSTEM "../../../lib/pkp/dtd/install.dtd">
3+
4+ <install version =" 3.3.5.0" >
5+ <migration class =" APP\plugins\generic\dataverse\classes\migrations\APITokenEncryptionMigration" />
6+ </install >
You can’t perform that action at this time.
0 commit comments