wirejs-deploy-amplify-basic 0.0.37 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/services/authentication.js +42 -15
- package/package.json +1 -1
|
@@ -212,10 +212,7 @@ export class AuthenticationService extends AuthenticationServiceBase {
|
|
|
212
212
|
state: 'unauthenticated',
|
|
213
213
|
user: undefined,
|
|
214
214
|
substate: 'pending-completesignup',
|
|
215
|
-
metadata:
|
|
216
|
-
email: form.inputs.email,
|
|
217
|
-
sub: result.UserSub,
|
|
218
|
-
})
|
|
215
|
+
metadata: form.inputs.email
|
|
219
216
|
});
|
|
220
217
|
return this.getMachineState(cookies);
|
|
221
218
|
}
|
|
@@ -274,8 +271,8 @@ export class AuthenticationService extends AuthenticationServiceBase {
|
|
|
274
271
|
return this.getMachineState(cookies);
|
|
275
272
|
}
|
|
276
273
|
try {
|
|
277
|
-
const
|
|
278
|
-
if (!email
|
|
274
|
+
const email = state.metadata;
|
|
275
|
+
if (!email) {
|
|
279
276
|
this.#cookie.clear(cookies);
|
|
280
277
|
return this.getMachineState(cookies);
|
|
281
278
|
}
|
|
@@ -284,11 +281,21 @@ export class AuthenticationService extends AuthenticationServiceBase {
|
|
|
284
281
|
Username: email,
|
|
285
282
|
ConfirmationCode: form.inputs.code
|
|
286
283
|
});
|
|
287
|
-
await client.send(command);
|
|
284
|
+
const result = await client.send(command);
|
|
285
|
+
const signinCommand = new InitiateAuthCommand({
|
|
286
|
+
ClientId,
|
|
287
|
+
AuthFlow: 'USER_AUTH',
|
|
288
|
+
Session: result.Session
|
|
289
|
+
});
|
|
290
|
+
const signinResult = await client.send(signinCommand);
|
|
291
|
+
signinResult.AuthenticationResult?.AccessToken;
|
|
292
|
+
const jwtPayload = jose.decodeJwt(
|
|
293
|
+
// assuming for now, until we support challenges like OTP, Email code, etc.
|
|
294
|
+
signinResult.AuthenticationResult?.IdToken);
|
|
288
295
|
await this.#cookie.write(cookies, {
|
|
289
296
|
state: 'authenticated',
|
|
290
297
|
user: {
|
|
291
|
-
id: sub,
|
|
298
|
+
id: jwtPayload.sub,
|
|
292
299
|
displayName: email,
|
|
293
300
|
username: email,
|
|
294
301
|
}
|
|
@@ -325,18 +332,38 @@ export class AuthenticationService extends AuthenticationServiceBase {
|
|
|
325
332
|
state: 'authenticated',
|
|
326
333
|
user: {
|
|
327
334
|
id: jwtPayload.sub,
|
|
328
|
-
username:
|
|
329
|
-
displayName:
|
|
335
|
+
username: form.inputs.email,
|
|
336
|
+
displayName: form.inputs.email,
|
|
330
337
|
},
|
|
331
338
|
});
|
|
332
339
|
return this.getMachineState(cookies);
|
|
333
340
|
}
|
|
334
341
|
catch (error) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
342
|
+
if (error.message === 'User is not confirmed.') {
|
|
343
|
+
const command = new ResendConfirmationCodeCommand({
|
|
344
|
+
ClientId,
|
|
345
|
+
Username: form.inputs.email
|
|
346
|
+
});
|
|
347
|
+
await client.send(command);
|
|
348
|
+
await this.#cookie.write(cookies, {
|
|
349
|
+
state: 'unauthenticated',
|
|
350
|
+
user: undefined,
|
|
351
|
+
substate: 'pending-completesignup',
|
|
352
|
+
metadata: form.inputs.email,
|
|
353
|
+
});
|
|
354
|
+
return {
|
|
355
|
+
...await this.getMachineState(cookies),
|
|
356
|
+
message: `Your account setup isn't complete.<br />
|
|
357
|
+
We sent you a new code to enter below.`
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
return {
|
|
362
|
+
errors: [{
|
|
363
|
+
message: error.message
|
|
364
|
+
}]
|
|
365
|
+
};
|
|
366
|
+
}
|
|
340
367
|
}
|
|
341
368
|
}
|
|
342
369
|
else if (isAction(form, 'changepassword')) {
|