Search code examples
mysqlreststrongloop

How can i get users details from MySql connector in the strongloop & remove "Authorization Required"


I'm trying to connect strongloop to MySql DB using connector, I'm able to get record of all the tables except "Users" which is having following details as [ { "userEmailId": "string", "userPassword": "string", "firstname": "string", "lastname": "string", "roleId": 0, "mobileNumber": "string", "userStatus": 0, "createdBy": 0, "createdDate": "2016-02-12", "modifiedBy": 0, "modifiedDate": "2016-02-12", "isdeleted": 0, "oldpassword": "string", "profilePicturename": "string", "address": "string", "userId": 0, "realm": "string", "username": "string", "credentials": {}, "challenges": {}, "email": "string", "emailVerified": true, "verificationToken": "string", "status": "string", "created": "2016-02-12", "lastUpdated": "2016-02-12" } ]

As Model Scema.

But when i create on get button @ url "http://localhost:3000/explorer/#!/User/User_find"

I'm getting { "error": { "name": "Error", "status": 401, "message": "Authorization Required", "statusCode": 401, "code": "AUTHORIZATION_REQUIRED", "stack": "Error: Authorization Required\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\loopback\\lib\\application.js:376:21\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\loopback\\lib\\model.js:313:7\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\loopback\\common\\models\\acl.js:465:23\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\async\\lib\\async.js:251:17\n at done (C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\async\\lib\\async.js:132:19)\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\async\\lib\\async.js:32:16\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\async\\lib\\async.js:248:21\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\async\\lib\\async.js:572:34\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\loopback\\common\\models\\acl.js:447:17\n at C:\\Users\\anupd\\Desktop\\loopback-getting-started\\node_modules\\loopback\\common\\models\\role.js:268:21" } }

Can anybudy help me to solve this problem or can tell me how can i extend inbuild User module to match myrequrements

Thanks in advance


Solution

  • we can't READ Inbuilt USER model. By default strongloop denied access.

    You just create custom model and inherit Inbuilt USER model then you will get all the features of Inbuilt USER model.

    Just do in your model.json. "base": "User",

    EX: model name like customer.js

     {
      "name": "customer",
      "base": "User",
      "idInjection": false,
      "options": {
        "validateUpsert": true
      },