amazon-archives / aws-cognito-angular-quickstart

An Angular(v5)-based QuickStart single-page app utilizing Amazon Cognito, S3, and DynamoDB (Serverless architecture)
https://cognito.budilov.com
Apache License 2.0
689 stars 302 forks source link

No record written in DynamoDB #97

Closed Nicosoft closed 7 years ago

Nicosoft commented 7 years ago

Hi,

The application works as expected except regarding one feature.

When the app fails to write into DynamoDB when a user login, logout. Same error to display data activity.

In the console I get the following 3 errors:

Here the screenshot of the console: ddb_cred_error-1 ](url)

I did use the provided script to create required resources in AWS. I get this error on my local machine and on S3.

Thank you for your help.

GBeushausen commented 7 years ago

I#ve got the same issue. Seems like the Cognito credentials are not valid. First they expire, even if session.isValid() = true. Second the credentials are not persisted and userservice.creds is undefined after pager reload.

vbudilov commented 7 years ago

I'm not seeing this. Every time I login or logout the message is written to DDB:

login Sun Aug 20 2017 00:06:41 GMT-0400 (EDT)
logout Sun Aug 20 2017 00:07:52 GMT-0400 (EDT)
login Sun Aug 20 2017 00:08:00 GMT-0400 (EDT)
login Sun Aug 20 2017 00:11:06 GMT-0400 (EDT)
GBeushausen commented 7 years ago

I get this error Message on logout. Login works and gets written to DynamoDB:

DynamoDb Error: TypeError: Cannot read property 'identityId' of undefined

vbudilov commented 7 years ago

That's probably because the credentials have expired by then. See https://github.com/awslabs/aws-cognito-angular2-quickstart/issues/83

You will need to implement the needed functionality to refresh the credentials within each hour of them being doled out.

GBeushausen commented 7 years ago

Ah ok thanks. I've seen that when i do a console.log on the credentials variable, it says it's expired. But if i check the session with the isValid() function it returns true. Strange.