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 304 forks source link

Error on loginComponent #15

Closed glangston83 closed 7 years ago

glangston83 commented 7 years ago

We're able to register, and confirm. When we attempt login however, we're getting the following:

EXCEPTION: Error in ./LoginComponent class LoginComponent - inline template:18:12 caused by: Cannot read property 'hex' of undefined

Issue seems to hit at this line: cognitoUser.authenticateUser(authenticationDetails, {

vbudilov commented 7 years ago

Have you included all of the required libraries per this following instructions? https://github.com/aws/amazon-cognito-identity-js

neojack647 commented 7 years ago

I posted this issue with https://github.com/aws/amazon-cognito-identity-js/issues/160#issuecomment-249733150 and replied back on https://github.com/bitwiseshiftleft/sjcl/issues/316 that there was still an issue. I have been unable to make headway on this and zone.js makes it impossible to find where it coming from. I have configured everything as requested for amazon-cognito-identity-js and ensured that codecBytes was included in the SJCL build. So any help would be appreciated.

vbudilov commented 7 years ago

The only time I saw this was when I updated my libraries to the latest versions. What I had to do is update ALL of the cognito-related libraries to the latest version. So try going to the link above and update all of the libraries:

    <script src="/path/to/jsbn.js"></script>
    <script src="/path/to/jsbn2.js"></script>
    <script src="/path/to/sjcl.js"></script>
    <script src="/path/to/aws-cognito-sdk.min.js"></script>
    <script src="/path/to/amazon-cognito-identity.min.js"></script>
    <script src="/path/to/aws-sdk-2.3.5.js"></script>

I took it a step further and updated to aws-sdk-2.6.* and it worked.

Please report back whether that worked (it did for me).

neojack647 commented 7 years ago

This is an issue with angular-cli and how it is loading scripts for webpack in the angular-cl.json file. SJCL is null in the amazon-cognito-identity.min.js file. I pulled down the amazon-cognito-identity-js project. Rebuilding amazon-cognito-identity.min.js so that SJCL is set to false for excluding 3rd party in the webpack.config.js file fixes this. Obviously forcing a 3rd party to included in the build is less than desirable but it does fix it for now.

vbudilov commented 7 years ago

Updated to angular 2.1.1

mixxr commented 7 years ago

@vbudilov I have the same issue, how did you fix it? thx

vbudilov commented 7 years ago

@mixxr ,

Try getting the latest version of this code. I've made many upgrades, including the aws sdk js version.

AdonousTech commented 7 years ago

If you include these files via angular-cli.json scripts array, you continue to get this error. A workaround is to list them separately in the root index.html file (as shown in this quick start).