Skip to content

Unable to set password column as 'password' #7

@jesseg34

Description

@jesseg34

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": []
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions