HIIT / mydata-sdk

Moved to https://github.com/mydata-sdk/mydata-sdk-1.x, HIIT repo is archived. Contains the different projects and libraries of MyData Service Development Kit. NOTE: Related Service Registry's code repository can be found at http://github.com/digitalhealthrevolution/serviceregistry
MIT License
8 stars 5 forks source link

Issues with account signup and login #1

Open elyesbh opened 7 years ago

elyesbh commented 7 years ago

Hi,

I have installed mydata-sdk using docker and I was able to open the corresponding web page http://127.0.0.1:8080.

However, when creating a new user account (sign-up), I was getting the following error:

2016-11-22 14:46:51,118 - app.mod_database.helpers in function log_query at line: 27 - DEBUG - SQL query to execute: "INSERT INTO MyDataAccount.Particulars (firstname, lastname, dateOfBirth, img_url, Accounts_id) VALUES (test, test, STR_TO_DATE(22-11-2016, '%Y-%m-%d'), img/avatars/mydata-avatar.png, 1)" 2016-11-22 14:46:51,118 - app.mod_database.helpers in function execute_sql_insert_2 at line: 98 - DEBUG - Error in SQL query execution: OperationalError(1292, "Truncated incorrect date value: '22-11-2016'")

I was able to fix the bug, by updating the lines "STR_TO_DATE(%s, '%%Y-%%m-%%d')" to "STR_TO_DATE(%s, '%%d-%%m-%%Y')" in the following file: Account/app/mod_database/models.py

Then, after having successfully created a new account, I'm getting the below error message when I try to login:

2016-11-22 14:50:02,301 - mod_auth_helpers in function get_account_by_username_and_password at line: 157 - DEBUG - Authenticated 2016-11-22 14:50:02,301 - mod_auth_helpers in function get_account_by_id at line: 25 - DEBUG - User info by acoount_id 2016-11-22 14:50:02,301 - mod_auth_helpers in function get_account_by_id at line: 27 - DEBUG - account_id: 1 2016-11-22 14:50:02,301 - mod_auth_helpers in function get_account_by_id at line: 48 - DEBUG - sql_query: "SELECT MyDataAccount.Accounts.id, MyDataAccount.LocalIdentities.id, MyDataAccount.LocalIdentities.username, MyDataAccount.Particulars.firstname, MyDataAccount.Particulars.lastname, MyDataAccount.Emails.email, MyDataAccount.Particulars.img_url, MyDataAccount.Particulars.dateOfBirth FROM MyDataAccount.Accounts INNER JOIN MyDataAccount.LocalIdentities ON MyDataAccount.Accounts.id = MyDataAccount.LocalIdentities.Accounts_id INNER JOIN MyDataAccount.Particulars ON MyDataAccount.Accounts.id = MyDataAccount.Particulars.Accounts_id INNER JOIN MyDataAccount.Emails ON MyDataAccount.Accounts.id = MyDataAccount.Emails.Accounts_id WHERE MyDataAccount.Accounts.id = '1' AND MyDataAccount.Emails.prime = 1" 2016-11-22 14:50:02,302 - mod_auth_helpers in function get_account_by_id at line: 54 - DEBUG - data: None 2016-11-22 14:50:02,302 - mod_auth_helpers in function get_account_by_id at line: 66 - DEBUG - Account not found: TypeError("'NoneType' object has no attribute '__getitem__'",) 2016-11-22 14:50:02,303 - mod_auth_helpers in function get_account_by_id at line: 69 - DEBUG - Exception: TypeError("'NoneType' object has no attribute '__getitem__'",) 2016-11-22 14:50:02,303 - mod_auth_controllers in function post at line: 59 - DEBUG - registered_user: None

hjhsalo commented 7 years ago

Hi elyesbh!

Thanks for reporting this issue. We have actually been discussing that should we even include a UI for MyData Account as the current one is more or less just a mockup from last spring. Current focus is to develop MyData Account as REST-service and then later provide a UI that uses this REST API. Current version is implemented by populating and rendering Jinja-templates in the backend.

Nevertheless we'll look into it but in the mean time you can verify that you have successfully deployed by running ui_flow.py without parameters. It should print "201 CREATED" if Consent Record was successfully delivered by the Operator to the Sink.

elyesbh commented 7 years ago

Thanks Hjhsalo for the clarifications.

I tried to run ui_flow.py (after a fresh redeploy) and I'm getting the below errors:

python ./ui_flow.py
http://localhost:8080/
http://localhost:5000/
False
582f2bf50cf2f4663ec4f020
582f2bf50cf2f4663ec4f01f
##### CREATE USER ACCOUNTS #####
NOTE: Throws an error if run for second time as you cannot create more accounts with same unique usernames. (Will be fixed in later releases.)
(500, 'Internal Server Error', u'{\n    "errors": {\n        "code": "500", \n        "detail": "OperationalError(1411, \\"Incorrect datetime value: \'2010-05-14\' for function str_to_date\\")", \n        "source": "/api/accounts/", \n        "status": "Internal Server Error, Server got itself in trouble", \n        "title": "Could not create Account"\n    }\n}', u'http://localhost:8080/api/accounts/')
...
##### CREATE A SERVICE LINK #####
Creation of first SLR failed with status (500) reason (INTERNAL SERVER ERROR) and the following content:
{
  "errors": [
    {
      "status": 500,
      "count": 0,
      "trace": null,
      "title": "INTERNAL SERVER ERROR",
      "detail": {
        "msg": "Something went wrong while Logging in with code to Service_Components Mgmnt",
        "Error from Service_Components Mgmnt": {
          "errors": [
            {
              "status": 500,
              "count": 0,
              "trace": [
                "Traceback (most recent call last):",
                "  File \"/mydata-sdk-components/Service_Components/Service_Mgmnt/service_mgmnt.py\", line 156, in post",
                "    title=result.reason)",
                "DetailedHTTPException: 500: Internal Server Error"
              ],
              "title": "INTERNAL SERVER ERROR",
              "detail": {
                "msg": "Something went wrong while redirecting verified code to Service_Components",
                "Error from Service_Components": {
                  "errors": [
                    {
                      "status": 500,
                      "count": 0,
                      "trace": [
                        "Traceback (most recent call last):",
                        "  File \"/mydata-sdk-components/Service_Mockup/DetailedHTTPException.py\", line 17, in wrapper",
                        "    result = method(self, *args, **kw)",
                        "  File \"/mydata-sdk-components/Service_Mockup/Service/service.py\", line 87, in post",
                        "    title=result.reason)",
                        "DetailedHTTPException: 500: Internal Server Error"
                      ],
                      "title": "INTERNAL SERVER ERROR",
                      "detail": {
                        "msg": "Something went wrong while posting to Service_Components Mgmnt to inform login was successful and its alright to generate Surrogate_ID ",
                        "Error from Service_Components Mgmnt": {
                          "errors": [
                            {
                              "status": 500,
                              "count": 0,
                              "trace": [
                                "Traceback (most recent call last):",
                                "  File \"/mydata-sdk-components/Service_Components/Service_Mgmnt/service_mgmnt.py\", line 122, in post",
                                "    title=result.reason)",
                                "DetailedHTTPException: 500: Internal Server Error"
                              ],
                              "title": "INTERNAL SERVER ERROR",
                              "detail": {
                                "msg": "Something went wrong while posting to Operator_SLR for /link",
                                "Error from Operator_SLR": {
                                  "errors": [
                                    {
                                      "status": 500,
                                      "count": 0,
                                      "trace": [
                                        "Traceback (most recent call last):",
                                        "  File \"/mydata-sdk-components/Operator_Components/DetailedHTTPException.py\", line 17, in wrapper",
                                        "    result = method(self, *args, **kw)",
                                        "  File \"/mydata-sdk-components/Operator_Components/Operator_SLR/registerSur.py\", line 185, in post",
                                        "    raise e",
                                        "DetailedHTTPException: 500: Internal Server Error"
                                      ],
                                      "title": "Internal Server Error",
                                      "detail": {
                                        "msg": "Getting surrogate_id from account management failed.",
                                        "content": {
                                          "errors": {
                                            "status": "Internal Server Error, Server got itself in trouble",
                                            "source": "/api/account/2/servicelink/",
                                            "code": "500",
                                            "detail": "KeyNotFoundError('Key for account not found from database', 'Could not get JWK object', 'Could not get public key from database')",
                                            "title": "Failed to get account owner's public key"
                                          }
                                        }
                                      },
                                      "source": "Not resolved",
                                      "id": "4d4df4fd-38a7-4e29-84a2-4012a11a9477"
                                    }
                                  ]
                                }
                              },
                              "source": "Not resolved",
                              "id": "41a27e92-40e1-41d2-a8c5-ce0a3adb1f9a"
                            }
                          ]
                        }
                      },
                      "source": "Not resolved",
                      "id": "f9d5e68b-fdcd-49ca-8952-ddc615685fd3"
                    }
                  ]
                }
              },
              "source": "Not resolved",
              "id": "7b6ed838-89ef-400c-a507-78df88fc79c7"
            }
          ]
        }
      },
      "source": null,
      "id": "b7689aa7-5ea3-46bd-a2d2-65480d579430"
    },
    {
      "status": 500,
      "count": 1,
      "trace": [
        "Traceback (most recent call last):",
        "  File \"/mydata-sdk-components/Operator_Components/Operator_SLR/start.py\", line 115, in get",
        "    title=result.reason)",
        "DetailedHTTPException: 500: Internal Server Error"
      ],
      "title": "SLR registration failed.",
      "detail": "Something failed during creation of SLR.",
      "source": "Not resolved",
      "id": "443cb8e2-34de-4405-b2a2-528d9f708116"
    }
  ]
}
Allu2 commented 7 years ago

I got it to work with following instructions

git clone https://github.com/HIIT/mydata-sdk
cd mydata-sdk
sudo sh start.sh  # Needed to run root only if you haven't configre docker to work with normal users

Wait till the stack has properly started last message I see is mysql-db | Version: '5.6.34' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)

Now open another terminal and run the ui_flow python ui_flow.py

hjhsalo commented 7 years ago

I'll include these start.sh / docker-compose -instructions in readme.md

elyesbh commented 7 years ago

Ok, thanks. I have tested the above four commands and my deployment is now ok ("status": 201, "msg": "CREATED"). I will focus on the REST APIs until the UI is fixed.