From 7a6b859fd9b2b7b4339691e71b0600a8a4f22d61 Mon Sep 17 00:00:00 2001 From: Cristina Ferrian <54667563+Bri74@users.noreply.github.com> Date: Tue, 27 Feb 2024 11:10:06 +0100 Subject: [PATCH] chore(auth): forward app version and build when logging in (#449) --- package-lock.json | 8 ++++---- package.json | 2 +- src/core/queries/authHooks.ts | 32 ++++++++++++++++++++++++-------- 3 files changed, 29 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 373a6976..1eb4638c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@miblanchard/react-native-slider": "^2.2.0", "@openspacelabs/react-native-zoomable-view": "^2.1.5", "@orama/orama": "^2.0.0-beta.8", - "@polito/api-client": "^1.0.0-ALPHA.57", + "@polito/api-client": "^1.0.0-ALPHA.58", "@react-native-async-storage/async-storage": "^1.17.11", "@react-native-clipboard/clipboard": "^1.12.1", "@react-native-community/blur": "^4.3.0", @@ -3828,9 +3828,9 @@ } }, "node_modules/@polito/api-client": { - "version": "1.0.0-ALPHA.57", - "resolved": "https://npm.pkg.github.com/download/@polito/api-client/1.0.0-ALPHA.57/6c09e8501536c32ac3fd63c1da0bbc6e169887ad", - "integrity": "sha512-gPcnAg1JUQyRLtWxQOWr1+gsZyMysqVAzXDbcLm52DuxJAwMsl6GsrqCTjF1mdVNZp3/KgBxIggIdoSjU2Untw==" + "version": "1.0.0-ALPHA.58", + "resolved": "https://npm.pkg.github.com/download/@polito/api-client/1.0.0-ALPHA.58/b4c2734ab51495a2c98a7e7640479448b8ab5e09", + "integrity": "sha512-DdQY3kIVOWzhyI3VvBAo30zx9TAa8lJ4yDByRnSDy72oopSKNb2V0XVLouC0dw9wYgd4fG9DLuMHrAG5g7FBnQ==" }, "node_modules/@react-native-async-storage/async-storage": { "version": "1.19.8", diff --git a/package.json b/package.json index 3f0f6489..93134d06 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@miblanchard/react-native-slider": "^2.2.0", "@openspacelabs/react-native-zoomable-view": "^2.1.5", "@orama/orama": "^2.0.0-beta.8", - "@polito/api-client": "^1.0.0-ALPHA.57", + "@polito/api-client": "^1.0.0-ALPHA.58", "@react-native-async-storage/async-storage": "^1.17.11", "@react-native-clipboard/clipboard": "^1.12.1", "@react-native-community/blur": "^4.3.0", diff --git a/src/core/queries/authHooks.ts b/src/core/queries/authHooks.ts index adbff8e7..fe14d4db 100644 --- a/src/core/queries/authHooks.ts +++ b/src/core/queries/authHooks.ts @@ -24,24 +24,40 @@ export const useLogin = () => { return useMutation({ mutationFn: (dto: LoginRequest) => { - dto.client = { name: 'Students app' }; + const client = { name: 'Students app' }; return Promise.all([ DeviceInfo.getDeviceName(), DeviceInfo.getModel(), DeviceInfo.getManufacturer(), + DeviceInfo.getBuildNumber(), + DeviceInfo.getVersion(), isEnvProduction ? messaging().getToken() : undefined, ]) - .then(([name, model, manufacturer, fcmRegistrationToken]) => { - dto.device = { + .then( + ([ name, - platform: Platform.OS, - version: `${Platform.Version}`, model, manufacturer, - }; - dto.preferences = { ...dto.preferences, fcmRegistrationToken }; - }) + buildNumber, + appVersion, + fcmRegistrationToken, + ]) => { + dto.device = { + name, + platform: Platform.OS, + version: `${Platform.Version}`, + model, + manufacturer, + }; + dto.client = { + ...client, + buildNumber, + appVersion, + }; + dto.preferences = { ...dto.preferences, fcmRegistrationToken }; + }, + ) .then(() => authClient.login({ loginRequest: dto })) .then(pluckData) .then(res => {