{"action":"created","issue":{"url":"https://api.github.com/repos/mcchrish/feathers-objection/issues/13","repository_url":"https://api.github.com/repos/mcchrish/feathers-objection","labels_url":"https://api.github.com/repos/mcchrish/feathers-objection/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/mcchrish/feathers-objection/issues/13/comments","events_url":"https://api.github.com/repos/mcchrish/feathers-objection/issues/13/events","html_url":"https://github.com/mcchrish/feathers-objection/issues/13","id":314285259,"number":13,"title":"NotAuthenticated response when including @feathersjs/authentication","user":{"login":"cdrandin","id":2958035,"avatar_url":"https://avatars0.githubusercontent.com/u/2958035?v=4","gravatar_id":"","url":"https://api.github.com/users/cdrandin","html_url":"https://github.com/cdrandin","followers_url":"https://api.github.com/users/cdrandin/followers","following_url":"https://api.github.com/users/cdrandin/following{/other_user}","gists_url":"https://api.github.com/users/cdrandin/gists{/gist_id}","starred_url":"https://api.github.com/users/cdrandin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdrandin/subscriptions","organizations_url":"https://api.github.com/users/cdrandin/orgs","repos_url":"https://api.github.com/users/cdrandin/repos","events_url":"https://api.github.com/users/cdrandin/events{/privacy}","received_events_url":"https://api.github.com/users/cdrandin/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-14T00:43:08Z","updated_at":"2018-04-19T18:33:38Z","closed_at":"2018-04-19T18:32:36Z","author_association":"NONE","body":"Most of the project setup was using feathers-cli.\r\n\r\n```bash\r\n> feathers g authentication\r\n\r\n? What authentication providers do you want to use? Other PassportJS strategies not in this list can still be configured manually. Username + Password (Local)\r\n? What is the name of the user (entity) service? users\r\n    force config/default.json\r\n   create src/authentication.js\r\n    force src/app.js\r\n```\r\n\r\n```javascript\r\n// users.models.js\r\n//\r\nconst {Model} = require('objection');\r\n\r\n/* eslint-disable no-console */\r\n\r\n// messages-model.js - A Objection.js/KnexJS\r\n//\r\n// See https://vincit.github.io/objection.js and http://knexjs.org/\r\n// for more of what you can do here.\r\n\r\nclass Users extends Model {\r\n  static get tableName() {\r\n    return 'users';\r\n  }\r\n\r\n  static get jsonSchema() {\r\n    return {\r\n      type: 'object',\r\n      required: [\r\n        'email', 'password'\r\n      ],\r\n\r\n      properties: {\r\n        id: {\r\n          type: 'integer'\r\n        },\r\n        email: {\r\n          type: 'string',\r\n          pattern: String.raw `^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$`\r\n        },\r\n        password: {\r\n          type: 'string',\r\n          'minLength': 4\r\n        }\r\n      }\r\n    };\r\n  }\r\n}\r\n\r\nmodule.exports = function(app) {\r\n  const db = app.get('knexClient');\r\n  const tableName = 'users';\r\n\r\n  db.schema.hasTable(tableName).then(exists => {\r\n    if (!exists) {\r\n      db.schema.createTable(tableName, table => {\r\n        table.increments();\r\n        table.string('email').unique().notNullable();\r\n        table.string('password', 100).notNullable();\r\n        table.timestamps(true, true);\r\n      }).then(() => console.log(`Created ${tableName} table`)).catch(e => console.error(`Error creating ${tableName} table`, e));\r\n    }\r\n  });\r\n\r\n  return Users\r\n};\r\n```\r\n\r\n```javascript\r\n// users.services.js\r\n//\r\n// Initializes the `users` service on path `/users`\r\nconst objectionService = require('feathers-objection');\r\nconst createModel = require('../../models/users.model');\r\nconst hooks = require('./users.hooks');\r\n\r\nmodule.exports = function(app) {\r\n  const Model = createModel(app);\r\n  const paginate = app.get('paginate');\r\n\r\n  const options = {\r\n    model: Model,\r\n    id: 'id',\r\n    paginate\r\n  };\r\n\r\n  // Initialize our service with any options it requires\r\n  app.use('/users', objectionService(options));\r\n\r\n  // Get our initialized service so that we can register hooks and filters\r\n  const service = app.service('users');\r\n\r\n  service.hooks(hooks);\r\n};\r\n```\r\n\r\nIt took me a bit of time to get it working properly with this setup. Feathers out of the box is pretty intense when not using NeDB (which apparently makes everything instantly work, had to manually setup a lot of other stuff).\r\n\r\nIn the app I tried\r\n\r\n```bash\r\napp.service('authentication')\r\n.create({strategy: 'local', email: '', password: ''})\r\n.then(console.log);\r\n```\r\n\r\nWhich processed just fine. Which leaves me to believe possibly I have it setup a bit incorrecting using objection to find my query. Something like `app.service('users').get(1).then(console.log);` works properly."},"comment":{"url":"https://api.github.com/repos/mcchrish/feathers-objection/issues/comments/382837319","html_url":"https://github.com/mcchrish/feathers-objection/issues/13#issuecomment-382837319","issue_url":"https://api.github.com/repos/mcchrish/feathers-objection/issues/13","id":382837319,"user":{"login":"cdrandin","id":2958035,"avatar_url":"https://avatars0.githubusercontent.com/u/2958035?v=4","gravatar_id":"","url":"https://api.github.com/users/cdrandin","html_url":"https://github.com/cdrandin","followers_url":"https://api.github.com/users/cdrandin/followers","following_url":"https://api.github.com/users/cdrandin/following{/other_user}","gists_url":"https://api.github.com/users/cdrandin/gists{/gist_id}","starred_url":"https://api.github.com/users/cdrandin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdrandin/subscriptions","organizations_url":"https://api.github.com/users/cdrandin/orgs","repos_url":"https://api.github.com/users/cdrandin/repos","events_url":"https://api.github.com/users/cdrandin/events{/privacy}","received_events_url":"https://api.github.com/users/cdrandin/received_events","type":"User","site_admin":false},"created_at":"2018-04-19T18:33:38Z","updated_at":"2018-04-19T18:33:38Z","author_association":"NONE","body":"Figured it out. When using `feathers generate authentication` with files that already existed it had trouble setting authenticate hooks into users.hooks.js"}}
{"actor":{"display_login":"cdrandin"}}