Skip to content

Commit

Permalink
chore(auth): forward app version and build when logging in (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bri74 authored Feb 27, 2024
1 parent 03059db commit 7a6b859
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
32 changes: 24 additions & 8 deletions src/core/queries/authHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 7a6b859

Please sign in to comment.