Skip to content

Commit 712f312

Browse files
committed
feat(iam): availability to sign with apple - send token to codemash and register/authenticate user
Apple doesn't provide web scenario for IOS devices. Instead you need to use accessToken and authorization code.
1 parent d659ec8 commit 712f312

File tree

2 files changed

+44
-10
lines changed

2 files changed

+44
-10
lines changed

src/components/iam.js

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function register({
2525
company,
2626
postalCode,
2727
gender,
28-
birthday,
28+
birthdate,
2929
roles,
3030
}) {
3131
const response = await server.loadJson(
@@ -59,7 +59,7 @@ export async function register({
5959
company,
6060
postalCode,
6161
gender,
62-
birthday,
62+
birthdate,
6363
roles,
6464
}),
6565
}
@@ -87,7 +87,7 @@ export async function registerGuest({
8787
company,
8888
postalCode,
8989
gender,
90-
birthday,
90+
birthdate,
9191
}) {
9292
const response = await server.loadJson(
9393
`${Config.apiUrl}${Endpoints.PROJECT.MEMBERSHIP.USERS.REGISTER}`,
@@ -118,7 +118,7 @@ export async function registerGuest({
118118
company,
119119
postalCode,
120120
gender,
121-
birthday,
121+
birthdate,
122122
}),
123123
}
124124
);
@@ -145,7 +145,7 @@ export async function invite({
145145
company,
146146
postalCode,
147147
gender,
148-
birthday,
148+
birthdate,
149149
roles,
150150
}) {
151151
const response = await server.loadJson(
@@ -177,7 +177,7 @@ export async function invite({
177177
company,
178178
postalCode,
179179
gender,
180-
birthday,
180+
birthdate,
181181
roles,
182182
}),
183183
}
@@ -206,7 +206,7 @@ export async function updateUser({
206206
company,
207207
postalCode,
208208
gender,
209-
birthday,
209+
birthdate,
210210
roles,
211211
}) {
212212
const response = await server.loadJson(
@@ -238,7 +238,7 @@ export async function updateUser({
238238
company,
239239
postalCode,
240240
gender,
241-
birthday,
241+
birthdate,
242242
roles,
243243
}),
244244
}
@@ -266,7 +266,7 @@ export async function updateProfile({
266266
company,
267267
postalCode,
268268
gender,
269-
birthday,
269+
birthdate,
270270
}) {
271271
const response = await server.loadJson(
272272
`${Config.apiUrl}${Endpoints.PROJECT.MEMBERSHIP.USERS.UPDATE_PROFILE}`,
@@ -297,7 +297,7 @@ export async function updateProfile({
297297
company,
298298
postalCode,
299299
gender,
300-
birthday,
300+
birthdate,
301301
}),
302302
}
303303
);
@@ -733,3 +733,36 @@ export async function deactivateAccount({secretKey, token, password}) {
733733
);
734734
return response;
735735
}
736+
737+
738+
export async function appleSignIn({
739+
identityToken,
740+
authorizationCode,
741+
fullName,
742+
}) {
743+
744+
const givenName = fullName?.givenName !== null || false ? fullName?.givenName : '';
745+
const familyName = fullName?.familyName !== null || false ? fullName?.familyName : '';
746+
747+
const response = await server.loadJson(
748+
`${Config.apiUrl}${Endpoints.PROJECT.MEMBERSHIP.USERS.SIGN_WITH_APPLE}?authorizationCode=${authorizationCode}&givenName=${givenName}&familyName=${familyName}`,
749+
{
750+
method: 'POST',
751+
headers: {
752+
'X-CM-ProjectId': Config.projectId,
753+
Authorization: `Bearer ${Config.secretKey}`,
754+
Accept: 'application/json',
755+
'Content-Type': 'application/json',
756+
},
757+
body: JSON.stringify({
758+
provider: 'apple',
759+
accessToken: identityToken,
760+
meta: { authorizationCode: authorizationCode,
761+
givenName: givenName,
762+
familyName: familyName,
763+
},
764+
}),
765+
}
766+
);
767+
return response;
768+
}

src/routes.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export const CONFIG = {
9595
CREATE_DEACTIVATION: '/v2/membership/users/deactivate/token',
9696
CHECK_DEACTIVATION: '/v2/membership/users/deactivate/token',
9797
DEACTIVATE_ACCOUNT: '/v2/membership/users/deactivate',
98+
SIGN_WITH_APPLE: '/v2/auth/apple'
9899
},
99100
},
100101
FILES: {

0 commit comments

Comments
 (0)