@@ -3,7 +3,7 @@ import { appleAuth, AppleRequestResponse } from '@invertase/react-native-apple-a
3
3
import { stateTree } from 'models' ;
4
4
import { KeychainStorage } from 'services/storage' ;
5
5
import { signinEMRPatient } from 'services/emr' ;
6
- import { mapFailure , mapSuccess } from 'fhir-react/src/services/service ' ;
6
+ import { isSuccess } from 'fhir-react/src/libs/remoteData ' ;
7
7
8
8
const AUTH_IDENTITY_KEYCHAIN_PATH = 'apple_identity' ;
9
9
@@ -46,21 +46,21 @@ export async function signin(authenticated: AuthenticatedAppleResponse) {
46
46
}
47
47
await KeychainStorage . store ( AUTH_IDENTITY_KEYCHAIN_PATH , identity ) ;
48
48
49
- mapSuccess (
50
- await signinEMRPatient ( authenticated . jwt , {
51
- name : {
52
- given : authenticated . username ?. givenName ?? undefined ,
53
- family : authenticated . username ?. familyName ?? undefined ,
54
- } ,
55
- } ) ,
56
- ( patient ) => stateTree . user . switchPatient ( patient ) ,
57
- ) ;
49
+ return await signinEMRPatient ( authenticated . jwt , {
50
+ name : {
51
+ given : authenticated . username ?. givenName ?? undefined ,
52
+ family : authenticated . username ?. familyName ?? undefined ,
53
+ } ,
54
+ } ) ;
58
55
}
59
56
60
57
export async function signinWithApple ( ) {
61
58
const authentication = await openAppleAuthenticationDialog ( ) ;
62
59
if ( authentication . status === AuthStatus . Authenticated ) {
63
- signin ( authentication ) ;
60
+ const response = await signin ( authentication ) ;
61
+ if ( isSuccess ( response ) ) {
62
+ stateTree . user . switchPatient ( response . data ) ;
63
+ }
64
64
}
65
65
return authentication ;
66
66
}
0 commit comments