File tree Expand file tree Collapse file tree 3 files changed +22
-20
lines changed
Expand file tree Collapse file tree 3 files changed +22
-20
lines changed Original file line number Diff line number Diff line change @@ -43,16 +43,8 @@ public static function respondToStorage() {
4343 $ owner = StorageServer::getOwner ();
4444
4545 $ allowedClients = $ owner ['allowedClients ' ] ?? [];
46- $ allowedOrigins = TRUSTED_APPS ?? [];
47- foreach ($ allowedClients as $ clientId ) {
48- $ clientRegistration = ClientRegistration::getRegistration ($ clientId );
49- if (isset ($ clientRegistration ['client_name ' ])) {
50- $ allowedOrigins [] = $ clientRegistration ['client_name ' ];
51- }
52- if (isset ($ clientRegistration ['origin ' ])) {
53- $ allowedOrigins [] = $ clientRegistration ['origin ' ];
54- }
55- }
46+ $ allowedOrigins = ($ owner ['allowedOrigins ' ] ?? []) + (TRUSTED_APPS ?? []);
47+
5648 if (!isset ($ origin ) || ($ origin === "" )) {
5749 $ allowedOrigins [] = "app://unset " ; // FIXME: this should not be here.
5850 $ origin = "app://unset " ;
Original file line number Diff line number Diff line change @@ -46,16 +46,7 @@ public static function respondToProfile() {
4646 $ owner = ProfileServer::getOwner ();
4747
4848 $ allowedClients = $ owner ['allowedClients ' ] ?? [];
49- $ allowedOrigins = TRUSTED_APPS ?? [];
50- foreach ($ allowedClients as $ clientId ) {
51- $ clientRegistration = ClientRegistration::getRegistration ($ clientId );
52- if (isset ($ clientRegistration ['client_name ' ])) {
53- $ allowedOrigins [] = $ clientRegistration ['client_name ' ];
54- }
55- if (isset ($ clientRegistration ['origin ' ])) {
56- $ allowedOrigins [] = $ clientRegistration ['origin ' ];
57- }
58- }
49+ $ allowedOrigins = ($ owner ['allowedOrigins ' ] ?? []) + (TRUSTED_APPS ?? []);
5950 if (!isset ($ origin ) || ($ origin === "" )) {
6051 $ allowedOrigins [] = "app://unset " ; // FIXME: this should not be here.
6152 $ origin = "app://unset " ;
Original file line number Diff line number Diff line change @@ -170,6 +170,21 @@ public static function getAllowedClients($userId) {
170170 return $ result ;
171171 }
172172
173+ public static function getAllowedOrigins ($ userId ) {
174+ Db::connect ();
175+ $ query = Db::$ pdo ->prepare (
176+ 'SELECT origin from clients LEFT JOIN allowedClients ON clients.clientId=allowedClients.clientId where allowedClients.userId=:userId '
177+ );
178+ $ query ->execute ([
179+ ':userId ' => $ userId
180+ ]);
181+ $ result = [];
182+ while ($ row = $ query ->fetch ()) {
183+ $ result [] = $ row ['origin ' ];
184+ }
185+ return $ result ;
186+ }
187+
173188 public static function getStorage ($ userId ) {
174189 Db::connect ();
175190 $ query = Db::$ pdo ->prepare (
@@ -214,6 +229,8 @@ public static function getUser($email) {
214229
215230 $ allowedClients = self ::getAllowedClients ($ userData ['userId ' ]);
216231 $ userData ['allowedClients ' ] = $ allowedClients ;
232+ $ allowedOrigins = self ::getAllowedOrigins ($ userData ['userId ' ]);
233+ $ userData ['allowedOrigins ' ] = $ allowedOrigins ;
217234 $ userData ['issuer ' ] = BASEURL ;
218235 $ storage = self ::getStorage ($ userData ['userId ' ]);
219236 if ($ storage ) {
@@ -239,6 +256,8 @@ public static function getUserById($userId) {
239256
240257 $ allowedClients = self ::getAllowedClients ($ userData ['userId ' ]);
241258 $ userData ['allowedClients ' ] = $ allowedClients ;
259+ $ allowedOrigins = self ::getAllowedOrigins ($ userData ['userId ' ]);
260+ $ userData ['allowedOrigins ' ] = $ allowedOrigins ;
242261 $ userData ['issuer ' ] = BASEURL ;
243262 $ storage = self ::getStorage ($ userData ['userId ' ]);
244263 if ($ storage ) {
You can’t perform that action at this time.
0 commit comments