Thanks for this 3 parts series of posting (User Roles & Management), It is very concise and complete.
I am trying to implement your example with knex and Postgres.
I download and run your code (server/Mongoose and client) and it works fine, super.
Changed the server part, I used knex/postgres instead of mongoose/mongodb.
Progressing step by step, skipping other details, in (server) user.hooks.js
create: [hashPassword("password")], it works fine and sends verification e-mail.
but if I add "verifyHooks.addVerification()" parameter,
create: [hashPassword("password"), verifyHooks.addVerification()],
it throws error as:
POST localhost:3030/users 400 (Bad Request) QAjaxBar.js?7ea5:65
and does NOT create a record in postgres database.
Another trial with knex, but SQLITE as the database;
it works fine with "verifyHooks.addVerification()" parameter, sends e-mail and CREATES a record in database, having "isVerified" as 0 (zero). But when I click the link in the e-mail, it doesn't complete verification steps and gives another error.
I used the same (knex) user model for both postgres and sqlite database cases.
// -----------------------------------------------------
db.schema
.dropTableIfExists("users")
.then(function () {
Is that a problem because of postgres' camelcase column name limitations?
What do you think about the source of problem would be?
Did you create any example with knex/Postgres similar to your example?
Thanks in advance for helping ideas on this issue.
Levent
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi Rachel,
Thanks for this 3 parts series of posting (User Roles & Management), It is very concise and complete.
I am trying to implement your example with knex and Postgres.
I download and run your code (server/Mongoose and client) and it works fine, super.
Changed the server part, I used knex/postgres instead of mongoose/mongodb.
Progressing step by step, skipping other details, in (server) user.hooks.js
// --------------------------------------
module.exports = {
before: {
all: [],
find: [authenticate("jwt")],
get: [authenticate("jwt")],
create: [hashPassword("password"), verifyHooks.addVerification()],
// create: [hashPassword("password")],
update: [hashPassword("password"), authenticate("jwt")],
patch: [hashPassword("password"), authenticate("jwt")],
remove: [authenticate("jwt")],
},
// ------------------------------------------------
in "before / create" hook if I run only
create: [hashPassword("password")], it works fine and sends verification e-mail.
but if I add "verifyHooks.addVerification()" parameter,
create: [hashPassword("password"), verifyHooks.addVerification()],
it throws error as:
POST localhost:3030/users 400 (Bad Request) QAjaxBar.js?7ea5:65
and does NOT create a record in postgres database.
Another trial with knex, but SQLITE as the database;
it works fine with "verifyHooks.addVerification()" parameter, sends e-mail and CREATES a record in database, having "isVerified" as 0 (zero). But when I click the link in the e-mail, it doesn't complete verification steps and gives another error.
I used the same (knex) user model for both postgres and sqlite database cases.
// -----------------------------------------------------
db.schema
.dropTableIfExists("users")
.then(function () {
// -----------------------------------------------------
Is that a problem because of postgres' camelcase column name limitations?
What do you think about the source of problem would be?
Did you create any example with knex/Postgres similar to your example?
Thanks in advance for helping ideas on this issue.
Levent