Giter Club home page Giter Club logo

bookshelf-secure-password's People

Contributors

dependabot[bot] avatar joeyrobert avatar mindgamesnl avatar sinan avatar truecarry avatar venables avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bookshelf-secure-password's Issues

model.authenticate throws a password mismatch error despite the passwords matching

I'm trying to use this plugin, but it's throwing PasswordMismatchError errors when I try to use it with test data.

Here is my login code. I'm testing with username = "[email protected]", password = "password", and usernameField = "email". And I've confirmed (with console.log) that these values are correct and that a user is being resolved by fetch.

return Model.forge({ [usernameField]: username })
  .fetch()
  .then((user) => {
    console.log({user, username, password, usernameField});
    if(!user) return null;
    return user.authenticate(password);
  })
  .catch((error) => {
    console.log('login error', error);
    return null;
  });

Here is my seed file that creates the user with the credentials above:

exports.seed = async (knex) => {
  const AdminUser = require('../lib/models/AdminUser');

  await knex('admin_users').del();
  await AdminUser.forge({
    first_name: 'admin',
    last_name: 'admin',
    email: '[email protected]',
    password: 'password',
  }).save();
};

And here is the model definition for AdminUser:

const AdminUser = app.model('AdminUser', {
  tableName: 'admin_users',
  hasSecurePassword: true,
  hasTimestamps: ['createdAt', 'updatedAt'],
});

bookshelf-secure-password will not install

when I try to install bookshelf-secure-password I get an error, I saw that it couldn't find bcrypt, so i tried installing it first but it still failed because it's looking for it in the wrong directory (my_folder/node_modules/bookshelf-secure-password/node_modules/bcrypt)
so how do I change this, can I change it? how do I install it?

I have tried on windows and linux systems and tried wit different node versoins it still doesn't work (crappy library)

bcrypt dependency out of date and fails install in NodeJs14

Running npm i using NodeJs14 fails due to out of date bcrypt dependency.

Changing bcrypt version to 5.0.0 resolves the issue and appears to function as expected within my project however I've not tested extensively. It would be great to get this dependency bumped if possible!

Unable to set password column as 'password'

I'm attempting to set the password database column as 'password' but there seems to be a problem specific to the string 'password'. When I attempt to save a model, the password is undefined. I can however change my column to anything other than 'password' and the plugin works as expected.

App info:
Typescript
knex 0.14.4
bookshelf 0.12.1
bookshelf-secure-password 3.0.1

Any help would be appreciated!

// userModel
import Database from '../db';

let db = Database.getInstance();
let bookshelf = db.getBookshelf();

export default class User extends bookshelf.Model<User> {
    get tableName() { return 'users'; }
    get hasTimestamps() { return true; }
    get hasSecurePassword() { return 'password'; }

}
// userRouter
...
public put(req: Request, res: Response, next: NextFunction) {
        new User(req.body)
        .save()
        .then((user) => {
            res.status(200)
            .send("'" + user.toJSON().username + "' was successfully created.");
        })
        .catch((err) => {
            res.status(500)
            .send(err);
        });
    }
...
// Error
{
    "code": "EREQUEST",
    "number": 515,
    "lineNumber": 1,
    "state": 2,
    "class": 16,
    "serverName": "xxxx",
    "procName": "",
    "originalError": {
        "info": {
            "number": 515,
            "state": 2,
            "class": 16,
            "message": "Cannot insert the value NULL into column 'password', table 'API.dbo.users'; column does not allow nulls. INSERT fails.",
            "serverName": "xxxx",
            "procName": "",
            "lineNumber": 1,
            "name": "ERROR",
            "event": "errorMessage"
        }
    },
    "name": "RequestError",
    "precedingErrors": []
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.