Selaa lähdekoodia

updated requests to send token as header

Abhinav-grd 4 vuotta sitten
vanhempi
commit
4aaebef0e7

+ 4 - 5
src/services/collectionService.ts

@@ -89,9 +89,8 @@ const getCollections = async (
 ): Promise<collection[]> => {
     try {
         const resp = await HTTPService.get(`${ENDPOINT}/collections`, {
-            token: token,
             sinceTime: sinceTime,
-        });
+        }, { 'X-Auth-Token': token, });
         const promises: Promise<collection>[] = resp.data.collections.map(
             (collection: collection) => getCollectionSecrets(collection, key)
         );
@@ -165,7 +164,7 @@ export const AddCollection = async (collectionName: string, type: CollectionType
 
 const createCollection = async (collectionData: collection, token: string): Promise<collection> => {
     try {
-        const response = await HTTPService.post(`${ENDPOINT}/collections`, collectionData, { token });
+        const response = await HTTPService.post(`${ENDPOINT}/collections`, collectionData, null, { 'X-Auth-Token': token });
         return response.data.collection;
     } catch (e) {
         console.log("create Collection failed " + e);
@@ -207,7 +206,7 @@ const addtoCollection = async (collection: collection, files: file[]) => {
             })
             return file;
         }));
-        await HTTPService.post(`${ENDPOINT}/collections/add-files`, params, { token });
+        await HTTPService.post(`${ENDPOINT}/collections/add-files`, params, null, { 'X-Auth-Token': token });
     } catch (e) {
         console.log("Add to collection Failed " + e);
     }
@@ -223,7 +222,7 @@ const removeFromCollection = async (collection: collection, files: file[]) => {
             }
             params["fileIDs"].push(file.id);
         }));
-        await HTTPService.post(`${ENDPOINT}/collections/remove-files`, params, { token });
+        await HTTPService.post(`${ENDPOINT}/collections/remove-files`, params, null, { 'X-Auth-Token': token });
     } catch (e) {
         console.log("remove from collection failed " + e);
     }

+ 6 - 4
src/services/fileService.ts

@@ -110,9 +110,11 @@ export const getFiles = async (collections: collection[], sinceTime: string, lim
                 resp = await HTTPService.get(`${ENDPOINT}/collections/diff`, {
                     collectionID: collection.id,
                     sinceTime: time,
-                    token,
                     limit,
-                });
+                },
+                    {
+                        'X-Auth-Token': token
+                    });
                 promises.push(...resp.data.diff.map(
                     async (file: file) => {
                         if (!file.isDeleted) {
@@ -148,8 +150,8 @@ export const getPreview = async (token: string, file: file) => {
         }
         const resp = await HTTPService.get(
             `${ENDPOINT}/files/preview/${file.id}`,
-            { token },
             null,
+            { 'X-Auth-Token': token },
             { responseType: 'arraybuffer' }
         );
         const worker = await new CryptoWorker();
@@ -173,8 +175,8 @@ export const getFile = async (token: string, file: file) => {
     try {
         const resp = await HTTPService.get(
             `${ENDPOINT}/files/download/${file.id}`,
-            { token },
             null,
+            { 'X-Auth-Token': token },
             { responseType: 'arraybuffer' }
         );
         const worker = await new CryptoWorker();

+ 2 - 3
src/services/uploadService.ts

@@ -261,7 +261,7 @@ class UploadService {
 
     private async uploadFile(uploadFile: uploadFile, token) {
         try {
-            const response = await HTTPService.post(`${ENDPOINT}/files`, uploadFile, { token });
+            const response = await HTTPService.post(`${ENDPOINT}/files`, uploadFile, null, { 'X-Auth-Token': token });
 
             return response.data;
         } catch (e) {
@@ -404,9 +404,8 @@ class UploadService {
             if (!this.uploadURLFetchInProgress) {
                 this.uploadURLFetchInProgress = HTTPService.get(`${ENDPOINT}/files/upload-urls`,
                     {
-                        token: token,
                         count: Math.min(50, count).toString()  //m4gic number
-                    })
+                    }, { 'X-Auth-Token': token })
                 const response = await this.uploadURLFetchInProgress;
 
                 this.uploadURLFetchInProgress = null;