strongloop / loopback-example-passport

LoopBack example for facebook login
Other
185 stars 134 forks source link

Getting error when accessing any of the methods through explorer ("Cannot call ACL.find(). The find method has not been setup. The PersistedModel has not been correctly attached to a DataSource!) #8

Closed 0xgeert closed 10 years ago

0xgeert commented 10 years ago

Just testing out of the box.

When trying any of the methods through localhost:3000/explorer I'm getting:

    {
      "error": {
        "name": "Error",
        "status": 500,
        "message": "Cannot call ACL.find(). The find method has not been setup. The PersistedModel has not been correctly attached to a DataSource!",
        "stack": "Error: Cannot call ACL.find(). The find method has not been setup. The PersistedModel has not been correctly attached to a DataSource!\n    at throwNotAttached (/home/geert-jan/sources/loopback-example-passport/node_modules/loopback/lib/models/persisted-model.js:63:9)\n    at Function.find (/home/geert-jan/sources/loopback-example-passport/node_modules/loopback/lib/models/persisted-model.js:168:3)\n    at Function.ACL.checkAccessForContext (/home/geert-jan/sources/loopback-example-passport/node_modules/loopback/lib/models/acl.js:397:8)\n    at Function.Model.checkAccess (/home/geert-jan/sources/loopback-example-passport/node_modules/loopback/lib/models/model.js:256:12)\n    at Function.<anonymous> (/home/geert-jan/sources/loopback-example-passport/node_modules/loopback/lib/application.js:319:13)\n    at execStack (/home/geert-jan/sources/loopback-example-passport/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:344:11)\n    at RemoteObjects.execHooks (/home/geert-jan/sources/loopback-example-passport/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:350:10)\n    at RemoteObjects.invokeMethodInContext (/home/geert-jan/sources/loopback-example-passport/node_modules/loopback/node_modules/strong-remoting/lib/remote-objects.js:472:8)\n    at /home/geert-jan/sources/loopback-example-passport/node_modules/loopback/node_modules/async/lib/async.js:610:21\n    at /home/geert-jan/sources/loopback-example-passport/node_modules/loopback/node_modules/async/lib/async.js:249:17"
      }
    }

I was expecting to get 401 instead.

I tried to check what the problem could be, but User etc are connected to datasource db which is correctly configured afaik. (I changed nothing at model-config.json and datasources.json)

btw: client-secrets, etc. are configured correctly and the webapp appears to function correctly as well.

Anyone knows that's up?

loopback : 2.1.4 loopback-example-passport: 2.0.0

raymondfeng commented 10 years ago

I went a bit too far. Some of the built-in models such as ACL lost the DB config. It should be fixed now in master.

0xgeert commented 10 years ago

yup, that solve it. Thanks!

malixsys commented 10 years ago

I'm getting it suddenly...

message: "Cannot call AccessToken.findById(). The findById method has not been setup. The PersistedModel has not been correctly attached to a DataSource!"
stack: "Error: Cannot call AccessToken.findById(). The findById method has not been setup. The PersistedModel has not been correctly attached to a DataSource!↵    at throwNotAttached (/Users/malixsys/Source/zoof/node_modules/loopback/lib/models/persisted-model.js:56:9)↵    at Function.find [as findById] (/Users/malixsys/Source/zoof/node_modules/loopback/lib/models/persisted-model.js:139:3)↵    at Function.AccessToken.findForRequest (/Users/malixsys/Source/zoof/node_modules/loopback/lib/models/access-token.js:126:10)↵    at /Users/malixsys/Source/zoof/node_modules/loopback/lib/middleware/token.js:53:16↵    at Layer.handle [as handle_request] (/Users/malixsys/Source/zoof/node_modules/loopback/node_modules/express/lib/router/layer.js:76:5)↵    at trim_prefix (/Users/malixsys/Source/zoof/node_modules/loopback/node_modules/express/lib/router/index.js:263:13)↵    at /Users/malixsys/Source/zoof/node_modules/loopback/node_modules/express/lib/router/index.js:230:9↵    at Function.proto.process_params (/Users/malixsys/Source/zoof/node_modules/loopback/node_modules/express/lib/router/index.js:305:12)↵    at /Users/malixsys/Source/zoof/node_modules/loopback/node_modules/express/lib/router/index.js:221:12↵    at Function.match_layer (/Users/malixsys/Source/zoof/node_modules/loopback/node_modules/express/lib/router/index.js:288:3)"
jayasrinagrale commented 7 years ago

I am getting this error. Using Loopback 3

Error: Cannot call ACL.find(). The find method has not been setup. The PersistedModel has not been correctly attached to a DataSource!

I am getting this error for programmatically defined models but not for models created using the generator.

nathanfletcher commented 7 years ago

Hi, please check your model-config.json file. I realised I had mistakenly removed the ACL part of it so please make sure that it is there like so...

  "ACL": {
    "dataSource": "db",
    "public": false
  },