Open ghost opened 8 years ago
Another update maybe necessary in > Chapter 5. Securing Applications with Authentication and Authorization --- Cookie authentication---routes.js
request.auth.session.clear();
request.auth.session.set({ username: request.payload.username, lastLogin: new Date() });
hapi-auth-cookie api updated as below:
When the cookie scheme is enabled on a route, the request.cookieAuth objects is decorated with the following methods:
- set(session) sets the current session. Must be called after a successful login to begin the session. session must be a non-null object, which is set on successful subsequent authentications in request.auth.credentials where: session - the session object.
- set(key, value) sets a specific object key on the current session (which must already exist) where: key - session key string. value - value to assign key.
- clear([key]) clears the current session or session key where: key - optional key string to remove a specific property of the session. If none provided, defaults to removing the entire session which is used to log the user out.
- ttl(msecs) sets the ttl of the current active session where: msecs - the new ttl in milliseconds.
Chapter 6. The joi of Reusable Validation --Validating hapi routes with joi --Validating route responses --
response: { schema: Joi.object().keys({ id: **Joi.string()**.min(4).max(40), details123: Joi.object() }), sample: 100, failAction: 'error' }
This will cause joi validate failed in Chapter 7. Making Your Application Production Ready--Persisting data---MongoDB
{ '_id' : ObjectID(userId)
since mongoDB ObjectID return an object but not a tring type value
Chapter 7. Making Your Application Production Ready --- Introducing logging---index.js
const goodOptions = { opsInterval: 3000, reporters: [ { reporter: require('good-console'), events: { ops: '*', response: '*', error: '*' } } ] };
good api changed as below:
const options = { ops: { interval: 1000 }, reporters: { console: [{ module: 'good-squeeze', name: 'Squeeze', args: [{ log: '*', response: '*' }] }, { module: 'good-console' }, 'stdout'] } };
Hi @littlstonee - I hope you'll forgive my delay in responding, I was on holidays the last few weeks. Thanks so much for these updates, I'll get these updates in over the next few days, and thank you for the feedback on the book!
Hi @littlstonee - just leaving this open as a reminder to update these. Thanks again for submitting them, completely missed this issue, apologies!!
Regarding the 'good' and 'good-console' example in Chapter 7, the section "Introducing logging", your code has still not been updated. I am probably not the first to say the examples and documentation for 'good' on npmjs.com and GitHub are not the easiest to follow. Some guidance would be really helpful. Thank you!
@pdcolvin - agreed :) Will try get on this soon, thanks for the reminder.
Hello @johnbrett , I just readed your book on safaribooksonline, it's really an awosome tutorial for hapi.js beginners. Thanks for the book.
While reading, I found a little piece of code maybe need be updated: Chapter 3 - Plugins/example 4 - Using Glue to Compose Our Server/index.js--line: 10)
plugins: [ { 'hapi-level': { path: './temp', config: { valueEncoding: 'json' } } }, { './user-store.js': {} }, { 'blipp': {} } ]
this causes a "plugins not allowed error" since Glue updated its registration api as belowregistrations: [ { plugin: { register: './assets', options: { uglify: true } } }]
for details, refer to https://github.com/hapijs/glue/blob/master/API.md
I'm not sure if an update is necessary, just for your reference. Thanks for the book again!