2020
2121use APP \core \Application ;
2222use APP \plugins \generic \thoth \classes \repositories \ThothAccountRepository ;
23+ use APP \plugins \generic \thoth \classes \repositories \ThothAbstractRepository ;
2324use APP \plugins \generic \thoth \classes \repositories \ThothAffiliationRepository ;
25+ use APP \plugins \generic \thoth \classes \repositories \ThothBiographyRepository ;
2426use APP \plugins \generic \thoth \classes \repositories \ThothBookRepository ;
2527use APP \plugins \generic \thoth \classes \repositories \ThothChapterRepository ;
2628use APP \plugins \generic \thoth \classes \repositories \ThothContributionRepository ;
3234use APP \plugins \generic \thoth \classes \repositories \ThothPublicationRepository ;
3335use APP \plugins \generic \thoth \classes \repositories \ThothReferenceRepository ;
3436use APP \plugins \generic \thoth \classes \repositories \ThothSubjectRepository ;
37+ use APP \plugins \generic \thoth \classes \repositories \ThothTitleRepository ;
3538use APP \plugins \generic \thoth \classes \repositories \ThothWorkRelationRepository ;
3639use APP \plugins \generic \thoth \classes \repositories \ThothWorkRepository ;
40+ use Illuminate \Contracts \Encryption \DecryptException ;
3741use Illuminate \Support \Facades \Crypt ;
3842use PKP \db \DAORegistry ;
3943use ThothApi \GraphQL \Client ;
@@ -48,14 +52,21 @@ public function register($container)
4852
4953 $ customThothApi = $ pluginSettingsDao ->getSetting ($ contextId , 'ThothPlugin ' , 'customThothApi ' );
5054 $ customThothApiUrl = $ pluginSettingsDao ->getSetting ($ contextId , 'ThothPlugin ' , 'customThothApiUrl ' );
51- $ email = $ pluginSettingsDao ->getSetting ($ contextId , 'ThothPlugin ' , 'email ' );
52- $ password = $ pluginSettingsDao ->getSetting ($ contextId , 'ThothPlugin ' , 'password ' ) ?? '' ;
55+ $ token = $ pluginSettingsDao ->getSetting ($ contextId , 'ThothPlugin ' , 'token ' ) ?? '' ;
56+ $ decryptedToken = '' ;
57+
58+ if ($ token ) {
59+ try {
60+ $ decryptedToken = Crypt::decrypt ($ token );
61+ } catch (DecryptException $ exception ) {
62+ $ decryptedToken = '' ;
63+ }
64+ }
5365
5466 return [
5567 'customThothApi ' => $ customThothApi ,
5668 'customThothApiUrl ' => $ customThothApiUrl ,
57- 'email ' => $ email ,
58- 'password ' => Crypt::decrypt ($ password )
69+ 'token ' => $ decryptedToken
5970 ];
6071 });
6172
@@ -68,13 +79,17 @@ public function register($container)
6879 }
6980
7081 $ client = new Client ($ httpConfig );
71- return $ client ->login ($ config ['email ' ], $ config [ ' password ' ]);
82+ return $ client ->setToken ($ config ['token ' ]);
7283 });
7384
7485 $ container ->set ('accountRepository ' , function ($ container ) {
7586 return new ThothAccountRepository ($ container ->get ('client ' ));
7687 });
7788
89+ $ container ->set ('abstractRepository ' , function ($ container ) {
90+ return new ThothAbstractRepository ($ container ->get ('client ' ));
91+ });
92+
7893 $ container ->set ('affiliationRepository ' , function ($ container ) {
7994 return new ThothAffiliationRepository ($ container ->get ('client ' ));
8095 });
@@ -83,6 +98,10 @@ public function register($container)
8398 return new ThothBookRepository ($ container ->get ('client ' ));
8499 });
85100
101+ $ container ->set ('biographyRepository ' , function ($ container ) {
102+ return new ThothBiographyRepository ($ container ->get ('client ' ));
103+ });
104+
86105 $ container ->set ('chapterRepository ' , function ($ container ) {
87106 return new ThothChapterRepository ($ container ->get ('client ' ));
88107 });
@@ -123,6 +142,10 @@ public function register($container)
123142 return new ThothSubjectRepository ($ container ->get ('client ' ));
124143 });
125144
145+ $ container ->set ('titleRepository ' , function ($ container ) {
146+ return new ThothTitleRepository ($ container ->get ('client ' ));
147+ });
148+
126149 $ container ->set ('workRelationRepository ' , function ($ container ) {
127150 return new ThothWorkRelationRepository ($ container ->get ('client ' ));
128151 });
0 commit comments