sails-permissions
sails-permissions copied to clipboard
sails-permissions does not work with sails-redis adapter
I started with the sails-permissions-example app here: https://github.com/ryanwilliamquinn/sails-permissions-example
It "sails lift"s and I am able to see the splashscreen and when I POST to /auth/local, I get "200 OK" back and an authenticated user.
I have redis running accessible on hostname "db" port 6379.
ksylvan@9fc3ebec3f42:/usr/src/app$ netcat db 6379
info
$1929
# Server
redis_version:3.0.3
redis_git_sha1:00000000
[...]
Now, apply this diff:
diff --git a/config/connections.js b/config/connections.js
index 3a8eefc..b1e509a 100644
--- a/config/connections.js
+++ b/config/connections.js
@@ -20,7 +20,13 @@
*/
module.exports.connections = {
-
+ redisHost: {
+ adapter: 'sails-redis',
+ port: 6379,
+ host: 'db',
+ password: null,
+ database: null,
+ },
/***************************************************************************
* *
* Local disk storage for DEVELOPMENT ONLY *
diff --git a/config/models.js b/config/models.js
index 27e5d79..846127b 100644
--- a/config/models.js
+++ b/config/models.js
@@ -11,6 +11,7 @@
module.exports.models = {
+ connection: 'redisHost',
/***************************************************************************
* *
* Your app's default connection. i.e. the name of one of your app's *
diff --git a/package.json b/package.json
index 04d182b..0918a56 100644
--- a/package.json
+++ b/package.json
@@ -25,7 +25,8 @@
"sails": "~0.11.0",
"sails-auth": "^1.3.1",
"sails-disk": "~0.10.0",
- "sails-permissions": "latest"
+ "sails-permissions": "latest",
+ "sails-redis": "^0.10.4"
},
"scripts": {
"debug": "node debug app.js",
The only difference is the connection to 'redisHost' (instead of the default 'localDisk').
sails lift now fails:
info: Starting app...
info: permissions: initializing sails-permissions hook
debug: sails-permissions: syncing waterline models
debug: sails-permissions: admin user does not exist; creating...
debug: Error (E_UNKNOWN) :: Encountered an unexpected error
AdapterError: Record does not satisfy unique constraints
at /usr/src/app/node_modules/sails-redis/lib/database/index.js:787:41
at /usr/src/app/node_modules/sails-redis/node_modules/redis/index.js:1170:13
at try_callback (/usr/src/app/node_modules/sails-redis/node_modules/redis/index.js:592:9)
at RedisClient.return_reply (/usr/src/app/node_modules/sails-redis/node_modules/redis/index.js:685:13)
at ReplyParser.<anonymous> (/usr/src/app/node_modules/sails-redis/node_modules/redis/index.js:321:14)
Connecting to the redis db, I see this:
get waterline:user:id:1
$167
{"username":"admin","email":"[email protected]","createdBy":1,"owner":1,"model":5,"createdAt":"2015-08-19T15:46:51.929Z","updatedAt":"2015-08-19T15:46:51.929Z","id":1}
get waterline:role:id:1
$115
{"name":"admin","active":true,"createdAt":"2015-08-19T15:46:51.893Z","updatedAt":"2015-08-19T15:46:51.894Z","id":1}
So it looks like the records are being created anyway. Not sure where to go next to try to debug this.
Closing this issue - Haven't worked on sails/nodejs for years and repo seems inactive.